title: How can I programmatically stop or start a website in IIS (6.0 and 7.0) using MsBuild?
body: <p>I have Windows Server 2003 (IIS 6.0) and Windows Server 2008 (IIS 7.0) servers, and I use MSBuild for deploying web applications.</p>
  
  <p>I need to do a safe deploy, and do this:</p>
  
  <ol>
  <li><p>Stop a website in IIS 6 (or an Application in IIS 7), not stop AppPool.</p></li>
  <li><p>Check if the website is stopped; not running.</p></li>
  <li><p>If the website is stopped, do another task for deploy.</p></li>
  <li><p>Start the website IIS 6 (or Application in IIS 7), </p></li>
  </ol>
  
  <p>How can I achieve this?</p>
  
  <p>Update: Key for me: IIS6WebSite and IIS6AppPool (and for IIS7), do wait for stopped status when try Stop Website or AppPool?</p>
  
  <p>When I execute Stop Action for Website (or Stop Action for AppPool), I need be sure 100% that Website is stopped, and then, and only if Website is Stopped, I can execute other targets.</p>