how run exe file in c# [duplicate]
I made an application that requires functionality to run iisreset.exe. My application is on deploy in server. so iisreset should be server not client machine. I use process.start() but it reset iis of client machine. what code i should modify.
Use the Process
class to execute a process.
How To: Execute command line in C#, get STD OUT results
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "YOURBATCHFILE.bat";
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
Use Process.Start()
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx
Tie into the OnExited event to get when it exits.
Further, consider the impact iisreset
has on the system as a whole. If others run sites on that same server, they may not be too happy with your software.
精彩评论