The processclass in csung allows convenient calling of external programs, so that we can use the cmd.exe program.
Add the parameter "/c" + command to execute a doscommand
(/C indicates that the domain name will be shut down after the specified command is executed. .exe/K6)
[Csharp]
Class ExampleOfLegalsoft
{
Private string RunCmd (string command)
{
// A Process class of the instance to start an independent Process
Process p = new Process ();
// The Process class has a StartInfo attribute. This is the ProcessStartInfo class, which includes some attributes and Methods. Below we use several of its attributes:
P. StartInfo. FileName = "cmd.exe"; // set the program name
P. StartInfo. Arguments = "/c" + command; // set program execution Parameters
P. StartInfo. UseShellExecute = false; // close Shell usage
P. StartInfo. RedirectStandardInput = true; // redirect standard input
P. StartInfo. RedirectStandardOutput = true; // redirect standard output
P. StartInfo. RedirectStandardError = true; // redirect error output
P. StartInfo. CreateNoWindow = true; // you can specify not to display a window.
P. Start (); // Start www.2cto.com
// P. StandardInput. WriteLine (command); // you can enter the command to be executed in this way.
// P. StandardInput. WriteLine ("exit"); // However, remember to add Exit. Otherwise, the next line of code will go live when it is executed.
Return p. StandardOutput. ReadToEnd (); // obtain the command execution result from the output stream
}
}
Author: stoneson