c# execute command line like command prompt? -
Text after "div class =" itemprop = "text">
I used to execute some command prompt lines in a global variable in C # and AC # code to store results Want to write code for the next part of the second part of the code?
I bought a device and I installed its driver. The only way to get your data is by using the command line in the command prompt. No API is available but, I want to do so in C # so that I am having trouble.
I have some code and it does not work for some reason. Note, I used logic input = "date" is for illustration purposes only. My job is not "date", but to get some logic data.
static void key (string [] args) {System.Diagnostics.Process Process = New System.Diagnostics.Process (); System.Diagnostics.ProcessStartInfo startInfo = New system. Diagnostics. Process STARTINFO (); StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; // CMD program startInfo.FileName = "cmd.exe"; // Set my debate date is just a dummy example. The actual work date is not used for startInfo.Arguments = "date"; StartInfo.RedirectStandardOutput = True; StartInfo.UseShellExecute = False; Process.start.info = startInfo; Process.start (); // capture that is generated in the command prompt var output = process.StandardOutput.ReadToEnd (); Write the output to the console / console. WrightLine (output); Process.WaitForExit (); Console.Read (); } Any help is appreciated.
After
You will need to use the CDD to launch to / c the date Use it.
Fixed zero main (string [] args) {System.Diagnostics.Process process = new System.Diagnostics.Process (); System.Diagnostics.ProcessStartInfo startInfo = New system. Diagnostics. Process STARTINFO (); StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; // CMD program startInfo.FileName = "cmd.exe"; // Set my debate date is just a dummy example. The actual work date is not used on StartInfo.Arguments = "/ c date"; StartInfo.RedirectStandardOutput = True; StartInfo.UseShellExecute = Wrong; Process.start.info = startInfo; Process.start (); // capture that is generated in the command prompt var output = process.StandardOutput.ReadToEnd (); Write the output to the console / console. WrightLine (output); Process.WaitForExit (); Console.Read (); } Flags / C and / K are your friends while using cmd.exe to launch other programs. If C / C is used to execute a program then exit CMD / K is used to execute a program, CMD is running.
Comments
Post a Comment