Search code examples
iiswindows-8nant

Start/Stop IIS website using Nant


Is there any way to stop/start website on IIS using Nant without stopping full service(w3svc)?

I saw this answer: IIS site and nant/nantcontrib? but as I discovered it not valid for server because after full IIS functionality adding from "Turn Windows features on or off" window I can't find iisweb.vbs file.


Solution

  • Found solution:

    <target name="start" >
        <exec program="C:\Windows\system32\inetsrv\appcmd.exe" >
            <arg line='start' />
            <arg line='sites' />
            <arg line='SiteName' />
        </exec>
    </target>   
    

    Make sure you have run nant task as Administrator(opened cmd to run nant as Administrator) to not fail always this target