Previous Table of Contents Next


We are not going to cover all of the various options of this command, but you can find more help about these options in the Books Online help file. You can access the Books Online help file by using the shortcut located on your Start menu or by running NET OptionName /? from the command line where OptionName is one of the options specified above (in between the [ ]). A summary of the NET command options and uses is listed in Table 12.1. For now, I’d like to point out the basic management functions that are duplicated in the Control Panel Services applet. These include the following formats of the NET command:


Note:  In the following discussion, ServiceName is the name of the service. If the service name contains spaces, be sure to surround ServiceName with quotes (“”); otherwise, an error message will be generated.
  NET START ServiceName—Use this format (with a specified service name) to start an inactive service. You can also use this command without a service name (NET START) to display a list of services currently running on your computer.
  NET STOP ServiceName—Use this format to stop a currently active service.
  NET PAUSE ServiceName—Use this format to pause a currently active service. Not all services support the pause option because some services can only be stopped, not paused.
  NET CONTINUE ServiceName—Use this format to continue a currently paused service.

I routinely use the NET command in my batch files to automate my system backups. The basic batch file is shown in Listing 12.2.

Listing 12.2 Using the NET command in a backup batch file.

@Echo Starting Monthly Batch Job > %SystemRoot%\Batch\Monthly.TXT
REM Pause server service to prevent clients from connecting
NET PAUSE SERVER

REM Warn connected clients that backup will occur and server will be
   shut down
NET SEND * "Performing Monthly Backup in 5 minutes. Close all open files
    and log off of server."

REM Wait for 4 minutes
SLEEP 240
NET SEND * "Performing Monthly Backup in 1 minute. Close all files now,
     log off of server immediately! Or risk data loss!!!&"

REM Wait for 1 minute
SLEEP 60

REM Stop Server service
NET STOP SERVER
REM Stop WINS service
NET STOP "Windows Internet Name Service"
REM Stop DHCP service
NET STOP "Microsoft DHCP Server"

REM Perform monthly backup
CALL %SystemRoot%\Batch\MonthlyBackup.CMD
@Echo Ending Monthly Batch Job >> %SystemRoot%\Batch\Monthly.TXT

REM Restart server service
NET START SERVER
REM Restart WINS service
NET START "Windows Internet Name Service"
REM Restart DHCP service
NET START "Microsoft DHCP Server"

REM Inform clients they may continue their work
NET SEND * "Monthly Backup Complete. You may continue work on the 
     file server."
Table 12.1 A summary of the NET command’s options and uses.

Option Description
ACCOUNTS Displays or configures the user account policies.
COMPUTER Adds or removes computer accounts.
CONFIG Displays or configures the Server or Workstation services.
CONTINUE Continues a paused service.
FILE Displays information on currently opened files, and allows you to close a currently open file.
GROUP Displays information about global groups on a computer, and allows you to perform basic global group management.
HELP Displays information about how to use the NET command and its options.
HELPMSG Displays a textual message for a specific numeric help identifier.
LOCALGROUP Displays information about local groups on a computer, and allows you to perform basic local group management.
NAME Displays information about network name aliases for a computer, and provides the ability to add or delete name aliases.
PAUSE Pauses a running service. Not all services support the Pause command.
PRINT Provides a command-line interface to submit a print job.
SEND Sends a text-based message to all domain users or to a specific user. In order for Windows NT users to receive the message, the Messenger service must be running. For a Windows 95 or 3.x computer to receive the message, WINPOPUP.EXE must be running.
SESSION Displays information about users currently connected to a computer, and provides the ability to forcibly disconnect a user from a computer.
SHARE Displays information about the shared folders on a computer, or provides the ability to manage new or existing shared folders.
START Starts an inactive service or can be used to display a list of currently active services.
STATISTICS Displays network statistics for the Server and Workstation services.
STOP Stops an active service.
TIME Synchronizes a computer’s local clock with the clock from another computer.
USE Displays information on the shared folders and printers a computer is connected to, or connects/disconnects to a shared folder or printer on another computer and assigns/unassigns a device name (drive letter or printer port).
USER Displays information about current user accounts defined on a computer, or provides basic user account management.
VIEW Displays a list of computers currently connected to the network, or displays a list of shared resources on a specific computer.


Previous Table of Contents Next