title: Start Stop IIS Application Pool
body: <p>I found this code:</p>
  
  <pre><code>using System.DirectoryServices;
  
  ...
  
  void Recycle(string appPool)
  {
      string appPoolPath = "IIS://servername/W3SVC/AppPools/" + appPool;
  
      using (DirectoryEntry appPoolEntry = new DirectoryEntry(appPoolPath))
      {
          appPoolEntry.Invoke("Recycle", null);
          appPoolEntry.Close();
      }
  }
  </code></pre>
  
  <p>But when I try to use this code I have this error:</p>
  
  <blockquote>
    <p>Exception has been thrown by the target of an invocation., StackTrace:    at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)</p>
  </blockquote>
  
  <p>What I'm doing wrong?<br/>
  or how can get info about status of my application pool, and how can I start and stop my app pool without any special permissions?</p>
  
  <p>I'am using built-in account: NetworkService</p>