Centralizing and automating any Windows NT shop requires some way to reach across a network to determine which services are running on a given server, examine how those services are configured (e.g., do they start up automatically or manually, do they have a service account associated with them), and change the configuration remotely. You can buy products to help with these tasks (for a review of one such product, see Oswald Forster, "ServiceKeeper 1.4.10," page 130). However, NT's Server Manager can also do many of these jobs. Server Manager replicates the Control Panel Services dialog box and can display that dialog box for any machine in its list of servers. But you can't control Server Manager from the command line, so it can't help you if you need to use a batch file to turn services on or off. Of course, you can use the Net Start and Net Stop commands to turn a service on and off, but only on the local computer.
The Microsoft Windows NT Server 4.0 Resource Kit Supplement 4 includes a script named service.vbs that lets you start or stop a service remotely. To shut down the DHCP server service on a remote machine named \charlie and restart the service, you could execute the commands
cscript service.vbs /x /n dhcpserver /s charlie cscript service.vbs /g /n dhcpserver /s charlie
These examples assume that \charlie recognizes you as an administrator. If not, your command can include the name and password of an administrator account. You use the /u option to specify the user account and the /w option to specify the password. If \charlie recognizes an administrative account named adminguy with password swordfish, you can start the DHCP server on \charlie with the command
cscript service.vbs /g /n dhcpserver /s charlie /u adminguy /w swordfish
Many other service.vbs options exist. The following command contains a short list (you can use the cscript service.vbs /? command to get the complete list):
cscript service.vbs <actionoption> /n <servicename> /s <servername> /u <adminaccount> /w <password>
Actionoption can be /g to start a service, /x to stop a service, /r to remove a service from the computer, or /d to list a service's dependencies. To find out a service's name, you can use the /l (i.e., list) option. For example, if I type
cscript service.vbs /l /s charlie
I'll see a list of all the services on \charlie (whether they're running or not), their display name (e.g., Microsoft DHCP Server), and their actual name (e.g., dhcpserver). Again, you might need to use the /u and /w options to specify a username and password for an administrator account.
Nifty as service.vbs is, it can't do every service-related task. I don't see a way to use service.vbs to change the name of the service account for services that don't use the standard "system" account. However, you can use the script to remotely install a service. First, you copy the file (or files) that makes up a service to the remote machine. For example, you can use the Net Use command to access an administrative share and copy the file to \winnt\system32. Then, you just type
cscript service.vbs /i /e <filename> /n <servicename> /c <displayname>
For filename, substitute the full pathname to the service's program file. Replace servicename with the service's short internal name (e.g., dhcpserver), and replace displayname with the display name (e.g., Microsoft DHCP Server). The command to install a new service that controls that wireless automatic lawnmower of yours might look like
cscript service.vbs /i /e c:\winnt\system32\buzz.exe /n mowrservice /c "Ronco Automatic Lawnmower Service"
Remember that perhaps the best thing about service.vbs is that, because it's a script, you have the source code. So, you can use it as a springboard to craft an even better utility.