1

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.

Community
  • 1
  • 1
Volodymyr
  • 1,209
  • 1
  • 15
  • 26

2 Answers2

0

Try this..

    <property name="YourServer" value="MyServerName" />

    <servicecontroller action="Stop" service="w3svc" machine="${YourServer}" timeout="10000" verbose="true" failonerror="false" /> 
    <servicecontroller action="Start" service="w3svc" machine="${YourServer}" timeout="10000" verbose="true" failonerror="false" /> 
Geddon
  • 1,266
  • 1
  • 11
  • 31
  • 1
    Hi, thanks for answer, but pay attention to situation description: **"without stopping full service"**, and this section stops and starts full service – Volodymyr May 21 '14 at 15:04
  • Ah. yes. I dont think came across an iisreset command from NAnt, but will check.. What's your reason for not stopping first? – Geddon May 22 '14 at 17:42
  • Deal is not in stopping, stop could be accepted but for specific site on IIS, but no full service(For example same action you could do at "IIS Manager"(console) for single site, for example "Root" -> "Sites" -> "Default Web Site"; but not in "Task Manager" -> "Services" tab(stop full w3svc service that is actually done by described upper Start/Stop actions)). – Volodymyr May 22 '14 at 19:06
0

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

Volodymyr
  • 1,209
  • 1
  • 15
  • 26
  • The problem I've found is that appcmd returns immediately and doesn't wait until the site is actually stopped. So if you subsequently try to copy in files, they could still be in use. – Tim Apr 19 '18 at 13:33