Reputation: 4111
Does someone knows how can I run "IISRESET" from c# application as if as I would run it from the start->run ?
Thanks.
Upvotes: 1
Views: 4155
Reputation: 47114
Process iisreset = new Process();
iisreset.StartInfo.FileName = "iisreset.exe";
iisreset.StartInfo.Arguments = "computername";
iisreset.Start();
Your C# application might need specific permission to launch it.
iisreset.exe
is located in the windows\system32
folder.
Upvotes: 2
Reputation: 6765
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();
Upvotes: 5
Reputation: 30810
System.Diagnostics.Process.Start("IISRESET.exe");
NOTE: You will need to provide correct path to IISRESET
as a parameter. Above is just a sample code.
Upvotes: 5