Home > Net >  C # use the CMD command to run an exe file input parameters are how to use the code output
C # use the CMD command to run an exe file input parameters are how to use the code output

Time:09-27

I wrote a python crawler, front form programming in c #, to invoke py script, and then I put the py script packaged into an exe file, want to use c # CMD command to run the exe, and then in the input parameters and output it stuck
Refer to
Or there are other methods can use c # direct call py script

CodePudding user response:

Don't sink sink don't don't don't don't sink sink sink

CodePudding user response:

C # can be directly run python code

CodePudding user response:

refer to the second floor small wind wind 12580 reply:
c # can be directly run a python code

Iornpython can't call some third-party libraries

CodePudding user response:

Nine years ago, must be to done in military industry, through the CMD startup company in c # software to calculate the secondary development, the input parameters and calculation results are obtained, specific do forget, baidu once, I remember is set manual calculation software using CMD start format (including input parameter), how do you call this exe developers should be clear and how return data,

CodePudding user response:

///& lt; Summary>
///Cmd command
///& lt;/summary>
///& lt; Param name="workingDirectory & gt;" To start the process catalog & lt;/param>
///& lt; Param name="command" & gt; To execute the command & lt;/param>
Public bool StartCmdBackup (string workingDirectory, string command)
{
Bool ret=true;
Process Process=new Process ();
Process. StartInfo. FileName=IBSystemContentUtil. S_cmdPath;
Process. StartInfo. WorkingDirectory=WorkingDirectory;
Process. StartInfo. UseShellExecute=false;
Process. StartInfo. RedirectStandardInput=true;
Process. StartInfo. RedirectStandardOutput=true;
Process. StartInfo. RedirectStandardError=true;
Process. StartInfo. CreateNoWindow=true;
Process. OutputDataReceived +=Process_OutputDataReceived;
Try
{
If (process. The Start ())
{
Process. StartInfo. Domain=process. Id. The ToString ();
Process. BeginOutputReadLine ();
Process. The StandardInput. WriteLine (command);
Process. The StandardInput. WriteLine (" exit ");
Process. The StandardInput. WriteLine (" exit ");
}
}
Catch Exception (es)
{
Ret=false;
}
The finally
{
Process. The Close ();
}
Return ret.
}

Private void Process_OutputDataReceived (object sender, DataReceivedEventArgs e)
{
Process Process=sender as Process;
if (! String. IsNullOrEmpty (e.D ata) & amp; & E.D ata. ContainsIgnoreCase (" exit "))
{
//process. Id
}
}

CodePudding user response:

C # using the command objects, perform: $pythonPatn/python xx. Py

CodePudding user response:

refer to 6th floor cyyno1 response:
c # using the command objects that perform: $xx pythonPatn/python. Py


So run py file directly
  •  Tags:  
  • C#
  • Related