C#运行应用程序

Ita*_*y.B 1 c#

有人知道如何从c#应用程序运行"IISRESET",就像我从start-> run运行它一样?

谢谢.

dec*_*one 5

System.Diagnostics.Process.Start("IISRESET.exe");
Run Code Online (Sandbox Code Playgroud)

注意:您需要提供正确的路径IISRESET作为参数.以上只是示例代码.


dje*_*eeg 5

System.Diagnostics.Process process = new System.Diagnostics.Process();
//process.StartInfo.FileName = @"C:\WINDOWS\system32\iisreset.exe";
process.StartInfo.FileName = "cmd";
process.StartInfo.Arguments = "/C iisreset /STOP";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
process.WaitForExit();
Run Code Online (Sandbox Code Playgroud)