用于检查IIS运行的脚本

时间:2010-01-12 18:43:51

标签: iis monitoring

如果停止,我想编写一个脚本来自动启动IIS服务器。

4 个答案:

答案 0 :(得分:3)

您可以使用IIS管理脚本来查询服务器,然后在需要时启动它。

该脚本位于%systemroot%\system32

要查询服务器,只需从命令行运行IIsWeb.vbs /query w3svc/1

如果它没有运行,那么你可以运行IIsWeb.vbs /start w3svc/1来启动它。

这是article,其中包含有关这些脚本的更多信息。

答案 1 :(得分:1)

  • 您可以在进程列表中查找w3wp.exe(如果它是IIS6)
  • 你总是可以尝试“iisreset / start” - 我相信,即使IIS已经启动它也能正常运行
  • 看看Microsoft在C:\Inetpub\AdminScripts中提供的脚本(假设默认安装位置),有startsrv.vbs,startweb.vbs - 两者都做得很好

答案 2 :(得分:1)

如果您担心iis在失败后没有重新启动,那么您可以做的一件简单事就是设置服务响应。如果您进入服务然后查看iis的属性,您将看到一个恢复选项卡。更改每个失败选项以重新启动服务。您还可以做的一件事是创建一个包含的批处理文件 IISRESET 并设置运行程序的选项,并将其作为您选择的程序。

答案 3 :(得分: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