2010-01-12 154 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