Monday, June 11, 2012

Batch file to restart IIS service


Batch file to restart service

net stop "IIS Admin Service"
net start "IIS Admin Service"

You can change the name in the quotes to whatever other service.  If you run it manually, make sure to "Run it as administrator".  If you are using it in a scheduled task, you will need to give it the necessary permissions

[EDIT]
If you get:
The following services are dependent on the IIS Admin Service service. Stopping the IIS Admin Service service will also stop these services.

World Wide Web Publishing Service
HTTP SSL

Do you want to continue this operation? (Y/N)

Then edit the batch file to include another parameter for this choice


net stop "IIS Admin Service" /yes
net start "IIS Admin Service"

[EDIT 2]
Apparently using the above will sometimes stop all websites


2 comments:

  1. will this start all other dependant services ?

    ReplyDelete
  2. No, it will not. You need to start all dependent services, with the service name (if there are spaces, you need to quote them out). Ex:
    Net stop spooler /yes
    net start spooler
    net start "citrix print spooler"
    exit

    ReplyDelete