title: How to verify my C# code run an IISRESET command in administrator mode
body: <p>I have created a windows service that checks a database for errors and if a specific one shows up I want it to perform an <code>IISRESET</code> command. </p>
  
  <p>The problem is, if I run and IISRESET command without the elevated privileges then it won't actually do the reset. So I have my code doing all I want, but I'm not sure if the <code>IISRESET</code> command is being run as an administrator and I don't know how to verify that.</p>
  
  <p><strong>Here is the code I have</strong></p>
  
  <pre><code>        ErrorCheckerEventLog.WriteEntry("Performing IISReset", EventLogEntryType.Warning);
          Process process = new Process();
          process.StartInfo.Verb = "runas";
          process.StartInfo.FileName = "iisreset.exe";
          process.StartInfo.UseShellExecute = true;
          process.StartInfo.CreateNoWindow = false;
          process.StartInfo.RedirectStandardError = false;
          process.StartInfo.RedirectStandardOutput = false;
          process.Start();
          process.WaitForExit();
          ErrorCheckerEventLog.WriteEntry("IISReset finished", EventLogEntryType.Information);
  </code></pre>
  
  <p><strong>In the Application event log I get these:</strong></p>
  
  <blockquote>
    <p>Listener Adapter protocol 'net.tcp' successfully connected to Windows Process Activation Service.</p>
    
    <p>Listener Adapter protocol 'net.pipe' successfully connected to Windows Process Activation Service.</p>
  </blockquote>
  
  <p><strong>In the system event log I get these:</strong></p>
  
  <blockquote>
    <p>IIS start command received from user testing\neil.kenny. The logged data is the status code.</p>
  </blockquote>
  
  <p>It all looks good to me, but I'm still not sure it actually did the reset. It could have just ran the iisreset command which then output the access denied message.</p>
  
  <p>How do I properly verify this?</p>