Possible Duplicate:
How to start a process from C#?
I want to start a external executable running in command line to do some task. After it is done, I want to check the errorcode it returns. How can I do it?
Try this:
public virtual bool Install(string InstallApp, string InstallArgs)
{
System.Diagnostics.Process installProcess = new System.Diagnostics.Process();
//settings up parameters for the install process
installProcess.StartInfo.FileName = InstallApp;
installProcess.StartInfo.Arguments = InstallArgs;
installProcess.Start();
installProcess.WaitForExit();
// Check for sucessful completion
return (installProcess.ExitCode == 0) ? true : false;
}
Process process = new Process();
process.StartInfo.FileName = "[program name here]";
process.StartInfo.Arguments = "[arguments here]";
process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
process.Start();
process.WaitForExit();
int code = process.ExitCode;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With