This question is very similar to Halt batch file until service stop is complete? but I would like to stop a website instead. I currently have appcmd stop sites "siteName"
in the script, but the batch file just issues the stop command and continues. I would like for the batch file to wait until the site is stopped before continuing. I'm running Windows Server 2008.
相关问题
- Inheritance impossible in Windows Runtime Componen
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- How can I have a python script safely exit itself?
- I want to trace logs using a Macro multi parameter
I could not figure out how to get this to work using a batch file. Something like this might work:
But I couldn't figure out how to modify the
set siteInfo="%x"
command so that it would work for the output of the appcmd command. The problem seemed to be that the appcmd output included double quotes and that interfered with command interpretation when the variable expansion is performed.Here's a PowerShell script that should work:
Does
appcmd
return immediately no matter what? This might work, depending on how appcmd behaves.If
appcmd
is a script, you could probably fix it so that it doesn't return immediately.What web server are you using?
Obviously you are using IIS 7 or newer if you are using APPCMD.
Try this to be sure you are executing the desired APPCMD:
"%windir%\system32\inetsrv\appcmd.exe" stop site "siteName"