JSI Tip 4875. How do I start, stop, and reboot IIS 5.0 from a command-line or batch?

Jerold Schulman

February 24, 2002

1 Min Read
ITPro Today logo in a gray background | ITPro Today


IIS 5.0 comes with the Iisreset.exe tool, which can take a server offline or start / stop services from the command-line.

The Iisreset.exe syntax is:

IISRESET [ computer name ] [ /option ] [ /option ] [....]

where:

No Parameters

Web services on the local computer are restarted.

/RESTART

Stops and restarts all running Internet services.

/START

Starts all Internet services that are configured to autostart.

/STOP

Stops all running Internet Services.

/REBOOT

Performs a Shutdown and restart of the computer.

/REBOOTONERROR    

If an error occurs while using the /RESTART, /START, or /STOP switches, the computer will be restarted.

/NOFORCE

If the /STOP fails, DO NOT force the Internet services to stop.

/TIMEOUT:Seconds

If /REBOOTONERROR is specified and an error occurs, wait Seconds, instead of the default, which is 20 seconds for the /RESTART switch and 60 seconds for the /STOP switch.

/STATUS

Displays the status of all Internet services.

/ENABLE

Enables the Restart API for Internet services.

/DISABLE

Disables the Restart API for Internet services.

Examples:

IISRESET /RESTART /REBOOTONERROR

Restart all running Internet services and reboot the local computer if the restart fails.

IISRESET /RESTART /TIMEOUT:120 /REBOOTONERROR

Restart all running Internet services and reboot the local computer if the restart fail to function in 120 seconds.

If you wanted to stop all Internet services, backup the log files, and start the services, use a batch file. I have elected to exit the batch if the stop fails:

@echo offIISRESET /STOP /NOFORCE if errorlevel == 1 goto :EOFcopy %systemroot%system32LogFilesW3SVC1*.* d:backupW3SVC1*.* /YIISRESET /START



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like