title: Restarting IIS programmatically
body: <p>I need to restart IIS from a C#/.NET application. This seems like a trivial issue, but I haven't had success thus far, and none of the answers from <a href="https://stackoverflow.com/questions/7870745/how-can-i-restart-iis-from-c-sharp-code-running-as-a-user-who-is-an-administrato">this question</a> have worked.</p>
  
  <p>I am a local administrator on the machine. </p>
  
  <p>I've tried this:</p>
  
  <pre><code>var process = new Process
  {
     StartInfo =
     {
         Verb = "runas",
         WorkingDirectory = @"C:\Windows\System32\",
         FileName = @"issreset.exe"
     }
  };
  process.Start();
  </code></pre>
  
  <p>but this throws a <code>Win32Exception - cannot find the file specified.</code> I've also tried various combinations of putting the whole path in <code>FileName</code>, and using <code>UseShellExecute</code> but neither of those options helped.</p>
  
  <p>I've also tried invoking it via the command line:</p>
  
  <pre><code>var process = new Process
  {
     StartInfo =
     {
         Verb = "runas",
         WindowStyle = ProcessWindowStyle.Hidden,
         FileName = @"cmd.exe",
         Arguments = "/C iisreset"
     }
  };
  process.Start();
  </code></pre>
  
  <p>and this works, but it gives a UAC prompt, which I cannot have as this application will be running without user intervention.</p>
  
  <p>Is there anything else I could try?</p>