In tip 2516, we configured service recovery using the GUI.

The preferred method for configuring service recovery on a remote computer is to use SC.EXE from the Windows 2000 Resource Kit Supplement (which can be installed on Windows 2000 Professional).

The general syntax for using SC.EXE is:

sc \[\\ServerName\] Command ServiceName \[OptionName=OptionValue...\]

Parameters

\\ServerName
Specifies the name of the server if you are running the commands on a remote computer. The name must start with two backslash characters (\\). If you are running the commands on the local computer, do not supply this parameter.
Command
Specifies one of the following SC commands:
Config Changes the configuration of a service (persistent).
Continue Sends a CONTINUE control request to a service.
Control Sends a control to a service.
Create Creates a service and adds it to the registry.
Delete Deletes a service from the registry.
Description Changes the description of a service.
EnumDepend Enumerates service dependencies.
Failure Changes the actions taken by a service upon failure.
GetDisplayName Gets the display name for a service.
GetKeyName Gets the name of the registry key for a service.
Interrogate Sends an INTERROGATE control request to a service.
Pause Sends a PAUSE control request to a service.
Qc Queries configuration for the service.
To find out the name of the binary for any service and whether it shares a process with other services, run sc qc ServiceName.
Qdescription Queries the description of a service.
Qfailure Queries the actions taken by a service upon failure.
Query Queries the status for a service or enumerates the status for types of services.
QueryEx Queries the status and extended information for a service, or enumerates the status and extended information for types of services.
SdShow Displays a service's security descriptor using SDDL.
SdSet Sets a service's security descriptor using SDDL.
Start Starts a service.
Stop Sends a STOP request to a service.

The following commands do not require a service name. Their syntax follows:
sc \[ServerName\] Command \[OptionName=OptionValue...\]

Boot Values are \{ok | bad\} Indicates whether to save the last restart configuration as the last-known-good restart configuration.
Lock Locks the Service Database.
QueryLock Queries the LockStatus for the SCManager Database.
ServiceName
specifies the name given to the service key in the registry. This is different from the display name that you see in Service.exe. You can get the ServiceName from the display name by running:

sc GetKeyName DisplayName
OptionName
specifies the name of an optional command parameter. You can supply from zero to any number of optional pairs of parameter names and values. For a list of available names, run:

sc Command where Command is a valid command name as listed above.
OptionValue
specifies the value for the parameter named by OptionName. For a list of available values, run:

sc Command where Command is a valid command name as listed above.

Help Information at the Command Prompt

Using SC without parameters displays help for the tool. To display help for specific SC commands, use the following command prompt syntax:

sc Command

where Command is a valid command name other than Query or QueryEx.

The Query and QueryEx commands cause SC to list the status of all running services. For information about the Query and QueryEx commands, run the command sc, and at the prompt "Would you like to see help for the QUERY and QUERYEX commands?" type: y

When you type SC failure, you receive:
<b>DESCRIPTION:
        Changes the actions upon failure
USAGE:
        sc failure \[service name\] <option1><option2>...

OPTIONS:
        reset= <length of period no failures seconds after which to reset the failure count be infinite>
                (Must be used in conjunction with actions= )
        reboot= <message broadcast before rebooting on failure>
        command= <command line to be run on failure>
        actions= <failure actions and their delay time milliseconds separated by slash e run valid are>  >
                  (Must be used in conjunction with the reset= option)</failure></command></message></length></option2></option1></b>
You might configure the Task Scheduler on a remote computer as follows: SC \\<ComputerName> failure Schedule reset= 3600 reboot="Restarting do to Schedule failure" actions= restart/5000/restart/5000/reboot/1000If you don't have the Resource Kit, you can manually configure the recovery and then export the service key. Here is an example of the Schedule service, after removing the unwanted Value Names and Keys:

REGEDIT4

\[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Schedule\]
"FailureCommand"="<Your batch file>"
"FailureActions"=hex:<Values based upon your,\
00,configuration,00
"RebootMessage"="<Your message>"

To configure all the remote computers in your domains, you can use Computers.bat to pass the <ComputerName> to the SC command or use Workstation.bat to run regedit /s filename.reg on the remote computers.