0

I want to iisreset a remote machine from my local using c#. iisreset /start is working from command prompt but when i am using the same script from c# code it is not working. Anyhelp would be really appreciated. Here is the code attached:

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new 
System.Diagnostics.ProcessStartInfo();
//startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/c iisreset <servername> /start";
process.StartInfo = startInfo;
process.Start();
maverickabhi
  • 197
  • 1
  • 6
  • 21
  • It's always best to define "not working" when posting this kind of question. Are you getting an exception? Is it not doing anything? Is it because you're running under an account that doesn't have permissions?... – Rufus L Nov 30 '17 at 01:51
  • Take a look at this answer in case it has to do with running your process as an administrator: https://stackoverflow.com/questions/19103599/restarting-iis-programmatically – Rufus L Nov 30 '17 at 01:54
  • 1
    Possible duplicate of [Restarting IIS programmatically](https://stackoverflow.com/questions/19103599/restarting-iis-programmatically) – Backs Nov 30 '17 at 02:56

0 Answers0