|
/// <Summary>
/// Run the doscommand
/// DOS process shutdown command (ntsd-c q-p PID) PID is the process ID
/// </Summary>
/// <Param name = "command"> </param>
/// <Returns> </returns>
Public static string RunCmd (string command)
{
// An example is a Process type, which initiates a pipeline.
System. Diagnostics. Process p = new System. Diagnostics. Process ();
// The Process class has a StartInfo atomicity. This is ProcessStartInfo class, which includes some attention and methods. We will use its attention below:
P. StartInfo. FileName = "cmd.exe"; // set the program name
P. StartInfo. Arguments = "/c" + command; // you can specify the number of rows in the program.
P. StartInfo. UseShellExecute = false; // use of related Shell
P. StartInfo. RedirectStandardInput = true; // redirect the standard ingress
P. StartInfo. RedirectStandardOutput = true; // redirect the mark to export
P. StartInfo. RedirectStandardError = true; // redirect zookeeper output
P. StartInfo. CreateNoWindow = true; // you can specify a non-empty window.
P. Start (); // dynamic
// P. StandardInput. WriteLine (command); // you can also use this method to export the command to be executed.
// P. StandardInput. WriteLine ("exit"); // you must remember to add Exit. Otherwise, the next line of program will become available.
Return p. StandardOutput. ReadToEnd (); // get the result of the command response line from the extract stream
}
|