2010-01-12 148 views

回答

3

您可以使用IIS管理腳本來查詢服務器,然後在需要時啓動它。

該腳本位於%systemroot%\system32

要查詢您的服務器,只需從命令行運行IIsWeb.vbs /query w3svc/1

如果它沒有運行,那麼你可以運行IIsWeb.vbs /start w3svc/1來啓動它。

這是一個article與這些腳本的更多信息。

1
  • 你可以找w3wp.exe的進程列表(如果是IIS6)
  • 你總是可以嘗試「IISRESET /開始」 - 我相信,它的工作原理即使IIS已經啓動
  • 起飛看看微軟在C:\Inetpub\AdminScripts提供的腳本(假設默認安裝位置),有startsrv.vbs,startweb.vbs - 既做好
+0

只有當服務當前處於活動狀態時纔會檢查它是否正在運行 – 2010-01-12 18:51:07

1

如果您擔心iis在失敗後未重新啓動,您可以執行的一件簡單的事情是設置服務響應。如果您進入服務,然後查看iis的屬性,您將看到一個恢復選項卡。更改每個故障選項以重新啓動服務。你還可以做的一件事是創建一個批處理文件,其中包括 iisreset 並設置運行程序的選項,並讓它成爲你選擇的程序。

0

發現了一些代碼在這裏:https://social.msdn.microsoft.com/Forums/en-US/5a01d88b-2b7c-4d0b-bce0-9b90a236b64a/how-to-check-if-iis-is-running?forum=asmxandxml

例子:

Dim sc As New System.ServiceProcess.ServiceController("World Wide Web Publishing Service") 

If sc.Status.Equals(System.ServiceProcess.ServiceControllerStatus.Stopped) Or sc.Status.Equals(System.ServiceProcess.ServiceControllerStatus.StopPending) Then 
    ' Start the service if the current status is stopped. 
    sc.Start() 
Else 
    ' Stop the service if its status is not set to "Stopped". 
    sc.Stop() 
End If 
相關問題