2016-04-30 87 views

回答

0

請嘗試下面提到的VB腳本代碼。我從我的一個工作腳本中刪除了這段代碼,如果發現任何錯誤,請發表評論。

iis_con= "localhost" 
set WMI_IIS = GetObject("IIS://" & iis_con & "/W3SVC") 
     if WMI_IIS.count = 0 then 
     ' do nothing 
     else 
      for each objitem in WMI_IIS 
       if objitem.class = "IIsWebServer" then 
        Select Case objItem.serverstate 
         Case 1:  wscript.echo("Starting") 
         Case 2:  wscript.echo("Running") 
         Case 3:  wscript.echo("Stopping") 
         Case 4:  wscript.echo("Stopped") 
         Case 5:  wscript.echo("Pausing") 
         Case 6:  wscript.echo("Paused") 
         Case 7:  wscript.echo("Continuing") 
         Case Default: wscript.echo("Unknown") 
        End Select 
       Next 
end if 
+0

感謝您的幫助@Amit。不完全符合我的要求。 立即在站點(少於一秒)啓動後,此代碼開始並繼續返回「2」運行狀態。 以下是轉換爲我用來測試的powershell的代碼。 while($ true){ $ site = get-wmiobject -namespace「root \ MicrosoftIISv2」-class「IIsWebServer」-ComputerName localhost -Filter「name ='w3svc/4'」 $ site.serverstate start-sleep - 毫秒10 } – lovedatsnow

+0

我不知道你使用的是IIS6 +,所以沒有提供WMI。那麼你現在面臨什麼問題?我沒有完全瞭解你的評論。 –

+0

是的,我正在使用IIS6 +。我仍然無法確定應用初始化完成的時間。 – lovedatsnow