暂停批处理文件,直到网站停止完成? [英] Halt batch file until website stop is complete?

查看:238
本文介绍了暂停批处理文件,直到网站停止完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题非常相似<一href=\"http://stackoverflow.com/questions/2874911/halt-batch-file-until-service-stop-is-complete\">Halt批处理文件,直到停止服务完成?但我想阻止一个网站来代替。我目前有 APPCMD停止网站的网站名称中的脚本,但批处理文件只是发出停止命令并继续。我想对于批处理文件等到现场继续之前停止。我运行Windows Server 2008。

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.

推荐答案

我无法弄清楚如何得到这个使用批处理文件的工作。事情是这样的可能的工作:

I could not figure out how to get this to work using a batch file. Something like this might work:

:LoopWhileNotStopped

for /f "delims=" %x in ('appcmd list site "siteName"') do set siteInfo="%x"

IF NOT %siteInfo:~-16% == "state:Stopped)"
    GOTO :LoopWhileNotStopped

但我无法弄清楚如何修改设置SITEINFO =%X命令,以便将用于的 APPCMD <输出工作/ em>的命令。这个问题似乎是,该的 APPCMD 的输出包括双引号和与命令干扰时进行变量扩展间pretation。

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.

下面是一个PowerShell脚本,应该工作:

Here's a PowerShell script that should work:

C:\Windows\System32\inetsrv\appcmd.exe stop site "siteName"

do { Start-Sleep -s 1; $siteInfo = C:\Windows\System32\inetsrv\appcmd.exe list site "siteName" } until ($siteInfo -match "state:Stopped")

这篇关于暂停批处理文件,直到网站停止完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆