开发者

how run exe file in c# [duplicate]

This question already has answers here: 开发者_C百科 Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜