2013-07-18 146 views

回答

0

是否appcmd立即返回? 这可能会起作用,具体取决于appcmd的行为。

start /wait "site stop" appcmd stop sites "siteName" 

如果appcmd是一个脚本,您可能可以修复它,以便它不会立即返回。

您使用的是什么Web服务器?

0

显然,如果您使用APPCMD,则使用IIS 7或更新版本。

  1. 我认为你的意思是SITE而不是SITES。
  2. 您的路径中可能有另一个文件名APPCMD。键入APPCMD /?看看你是否 执行你的想法。
  3. 试试这个,以确保您正在执行所需的APPCMD:

    “%WINDIR%\ SYSTEM32 \ INETSRV \ Appcmd.exe的” 一站式网站的 “网站名称”

0

我无法弄清楚如何让这个工作使用批处理文件。事情是这样的威力工作:

:LoopWhileNotStopped 

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

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

但我无法弄清楚如何修改set siteInfo="%x"命令,这样它会为输出工作APPCMD命令。问题似乎是,输出包含双引号,并且在执行变量扩展时会干扰命令解释。

这里的PowerShell脚本应该工作:

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")