Recipe12.2.Stopping and Starting IIS


Recipe 12.2. Stopping and Starting IIS

Problem

You want to stop and restart IIS as a whole, individual IIS services, or individual sites.

Solution

Using a graphical user interface

  1. Open Internet Information Services (IIS) Manager.

  2. To restart all IIS services on the server:

    1. In the left pane, right-click on the server node and select All Tasks

      Choose whether to restart IIS, stop IIS, start IIS, or reboot the server and click OK.

  3. To restart an individual web or FTP site, right-click on the node for the site and select Stop, then repeat and select Start.

Using a command-line interface

The following command restarts all IIS services on the computer:

> iisreset

To stop IIS services on a remote computer with IP address 172.16.12.5 do the following:

> iisreset 172.16.12.5 /stop

To verify that IIS services have been stopped on the remote computer, do the following:

> iisreset 172.16.12.5 /status

To prevent iisreset from being used to stop IIS services, type the following command at the local console of your IIS computer:

> iisreset /disable

To stop the WWW service only on your IIS computer:

> net stop w3svc

To start it again:

> net start w3svc

To stop the IISAdmin service and all dependent IIS services:

> net stop /y iisadmin

To stop the Default Web Site only while leaving other web sites running, use this command:

> iisweb /stop "Default Web Site"

To start it again:

> iisweb /start "Default Web Site"

Using VBScript
' This code stops and starts the specific web site. ' ------ SCRIPT CONFIGURATION ------ strComputer = "<ServerName>"  'e.g., web01.rallencorp.com strPath = "<IISPath>"         'e.g., W3SVC/1 ' ------ END CONFIGURATION --------- set objIIS = GetObject("IIS://" & strComputer & "/" & strPath)     objIIS.Stop WScript.Echo "Web site " & strComputer & "/" & strPath & " successfully stopped"     objIIS.Start WScript.Echo "Web site " & strComputer & "/" & strPath & " successfully started"

Discussion

In previous versions of IIS, you often had to restart IIS frequently to keep a flaky application running. With IIS 6, you can use application pool recycling (see Recipe 12.23) instead, which restarts only the worker processes associated with that application and leaves other applications running. The only time you should need to restart IIS using the procedures outlined above is when you make a major configuration change to your computer, such as installing a new ISAPI filter or COM component.

Using a graphical user interface

If you can't restart IIS using IIS Manager, it means you may have disabled restarts by running iisreset /disable on your computer previously. Run iireset /enable and try again.

Using a command-line interface

To stop and start the FTP service, use net stop msftpsvc and net start msftpsvc (or the sc equivalents), and to stop and start individual FTP sites, use the iisftp.vbs command script.

Using a VBScript

If you want to restart a particular web or FTP site, set the strPath variable to the name of the service (e.g., W3SVC) followed by a forward slash and the numeric identifier for the site as seen in IIS Manager. To restart all IIS web services, set strPath to W3SVC.

See Also

Recipe 7.1 and Recipe 12.23



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net