Script to check IIS running or not

14,510

Solution 1

You can use the IIS Admin Scripts to query the server, and then start it if you need.

The script is located in %systemroot%\system32.

To query you server, just run IIsWeb.vbs /query w3svc/1 from a command line.

If it's not running, then you can run IIsWeb.vbs /start w3svc/1 to start it.

Here is an article with more information on these scripts.

Solution 2

  • you can look for w3wp.exe in the process list (if it's IIS6)
  • you can always try "iisreset /start" - I believe, it works even if IIS is already started
  • take a look at the scripts provided by Microsoft in C:\Inetpub\AdminScripts (assuming default install location), there is startsrv.vbs, startweb.vbs - both do a good job

Solution 3

One simple thing you can do if you are worried about iis not restarting after it fails is to set the services responses. If you go into services and then look at the properties for iis, you will see a recovery tab. Change each of the failure options to restart the service. one thing you could also do is create a batch file that includes iisreset and set the option to run program and have that be the program you select.

Share:
14,510
Yogendra Bhardwaj
Author by

Yogendra Bhardwaj

Updated on October 14, 2022

Comments

  • Yogendra Bhardwaj
    Yogendra Bhardwaj over 1 year

    I would like to write a script to start IIS server automatically if it is stopped.

  • Lucas B
    Lucas B over 14 years
    that is only if the service is currently active, that does not check if it is running
  • Martin_W
    Martin_W about 3 years
    IIsWeb.vbs does not exist on Windows 10 Professional.