DekGenius.com
[ Team LiB ] Previous Section Next Section

13.2 Stopping and Starting the DNS Server Service

There are a couple of options for stopping and starting the DNS server on Windows Server 2003. The net stop and net start commands have been around since the early days of Windows NT and are commonly used to stop and start services, if for no other reason than their availability and simplicity. You specify the name of the service after the command to stop or start it. Here is an example of restarting the DNS server in two steps using these commands:

C:\> net stop dns
The DNS Server service is stopping.
The DNS Server service was stopped successfully.

C:\> net start dns
The DNS Server service is starting.
The DNS Server service was started successfully.

While these commands are certainly easy to use, they don't work on a remote server. If you need to stop, start, or restart the DNS server on a remote server, you'll need to use the sc utility.

In Windows 2000, the sc utility was available in the Resource Kit. In Windows Server 2003, it's installed with the operating system, like the syscomgr and net commands we described earlier.

Not only can sc be run against remote servers, but it provides options to perform just about any action you would need to do against a service. To restart the DNS server on a remote server named matrix, we would use the following commands:

C:\> sc \\matrix stop dns

SERVICE_NAME: dns
 TYPE               : 10  WIN32_OWN_PROCESS
 STATE              : 3  STOP_PENDING
                         (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
 WIN32_EXIT_CODE    : 0  (0x0)
 SERVICE_EXIT_CODE  : 0  (0x0)
 CHECKPOINT         : 0x1
 WAIT_HINT          : 0x7530

C:\> sc \\matrix start dns

SERVICE_NAME: dns
 TYPE               : 10  WIN32_OWN_PROCESS
 STATE              : 2  START_PENDING
                         (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN))

 WIN32_EXIT_CODE    : 0  (0x0)
 SERVICE_EXIT_CODE  : 0  (0x0)
 CHECKPOINT         : 0x0
 WAIT_HINT          : 0x7d0
 PID                : 504
 FLAGS              :

As you can see, the second command returned a START_PENDING state. To verify the service started successfully, we can use the query option:

C:\> sc \\matrix query dns

SERVICE_NAME: dns
 TYPE               : 10  WIN32_OWN_PROCESS
 STATE              : 4  RUNNING
                         (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
 WIN32_EXIT_CODE    : 0  (0x0)
 SERVICE_EXIT_CODE  : 0  (0x0)
 CHECKPOINT         : 0x0
 WAIT_HINT          : 0x0

We recommend using sc instead of the net command. In its most basic form, sc is just as simple but much more powerful. The following help entry lists all the options supported by sc:

DESCRIPTION:
        SC is a command line program used for communicating with the
        Service Control Manager and services.
USAGE:
        sc <server> [command] [service name] <option1> <option2> . . . 

     The option <server> has the form "\\ServerName"
     Further help on commands can be obtained by typing: "sc [command]"
     Commands:
     query-----------Queries the status for a service, or
                     enumerates the status for types of services.
     queryex---------Queries the extended status for a service, or
                     enumerates the status for types of services.
     start-----------Starts a service.
     pause-----------Sends a PAUSE control request to a service.
     interrogate-----Sends an INTERROGATE control request to a service.
     continue--------Sends a CONTINUE control request to a service.
     stop------------Sends a STOP request to a service.
     config----------Changes the configuration of a service (persistent).
     description-----Changes the description of a service.
     failure---------Changes the actions taken by a service upon failure.
     qc--------------Queries the configuration information for a service.
     qdescription----Queries the description for a service.
     qfailure--------Queries the actions taken by a service upon failure.
     delete----------Deletes a service (from the registry).
     create----------Creates a service. (adds it to the registry).
     control---------Sends a control to a service.
     sdshow----------Displays a service's security descriptor.
     sdset-----------Sets a service's security descriptor.
     GetDisplayName--Gets the DisplayName for a service.
     GetKeyName------Gets the ServiceKeyName for a service.
     EnumDepend------Enumerates Service Dependencies.

     The following commands don't require a service name:
     sc <server> <command> <option>
     boot------------(ok | bad) Indicates whether the last boot should
                     be saved as the last-known-good boot configuration
     Lock------------Locks the Service Database
     QueryLock-------Queries the LockStatus for the SCManager Database
EXAMPLE:
     sc start MyService
    [ Team LiB ] Previous Section Next Section