Creating a Custom Startup Verification Program

System startup is usually declared "good" if the following two procedures are complete:

When a service fails to load during startup, its ErrorControl value is checked, as defined in the CurrentControlSet\Services\Servicename subkeys. Whether the system startup process continues or halts depends on this value.

This basic standard for verifying system startup suits the needs of most situations; however, your site might require additional steps before considering a computer to be successfully started and ready to participate in the network.

For example, you can redefine startup validation for a server no one normally logs on to, or for which you want system startup to be validated as successful only after a particular process has started.

Or, for a server running Microsoft SQL Server, you might want a system startup to be marked as good only after the server responds to a request. To do this, you can write a program that queries the SQL database and checks the response. If the response is not as expected, the program can call the NotifyBootConfigStatus() function with a value of FALSE, prompting the system to restart by using the LastKnownGood control set. Or, the program can direct the system to run without saving the current configuration as the LastKnownGood control set. Conversely, if SQL Server responds as expected, the program can call the NotifyBootConfigStatus() function with a value of TRUE, which prompts the system to save the current configuration as the LastKnownGood control.

You can run such a verification program from the command prompt. Or you can have the program run automatically during startup by specifying value entries under the BootVerificationProgram subkey in the Registry.

To create a custom startup verification program

1. Change the value of ReportBootOK to 0 under the following Registry path:

HKEY_LOCAL_MACHINE\Software
\Microsoft
\Windows NT
\CurrentVersion
\WinLogon

The data type for ReportBootOK is REG_SZ. When the value of ReportBootOK is set to 0, it disables the automatic acceptance of startup after the first successful logon.

2. Create the executable program that you want to run as part of startup verification. Then specify its filename as a value for ImagePath in the BootVerificationProgram subkey under this Registry path:

HKEY_LOCAL_MACHINE\System
\CurrentControlSet
\Control
\BootVerificationProgram

The data type for ImagePath must be REG_SZ or REG_EXPAND_SZ.

As another example, a computer setup for a turnkey application is a candidate for a custom startup verification routine: The computer does not usually interact directly with users and you therefore do not want a successful user logon to be part of the system startup.

If you want a good system startup to be accepted from a remote computer (either manually or automatically), you can use the Bootvrfy.exe program that is supplied with Windows NT. In this case, the remote computer accepts the system startup by starting the Bootvrfy service. You can also write your own verification service, which can reject the system startup and revert to the LastKnownGood control set to restart the computer.

To verify system startup from a remote computer

1. For the local computer, add a BootVerification subkey under the following Registry path:

HKEY_LOCAL_MACHINE\System
\CurrentControlSet
\Services

2. Add the following value entries under this new BootVerification key:


Start : REG_DWORD : 0x00000003
Type : REG_DWORD : 0x00000020
ErrorControl : REG_DWORD : 0x00000001
ImagePath : REG_EXPAND_SZ : bootvrfy.exe
ObjectName : REG_SZ : LocalSystem

For more information about these entries, see Regentry.hlp, the Registry Help file on the Windows NT Workstation Resource Kit CD.

3. Change the value of ReportBootOK to 0 under the following Registry path:

HKEY_LOCAL_MACHINE\Software
\Microsoft
\Windows NT
\CurrentVersion
\WinLogon

4. Start the Bootvrfy service from a remote computer.

This service tells the service controller on the local computer to save the current startup configuration as the LastKnownGood configuration, and then the service terminates itself.

Important

You cannot use the Bootvrfy service in conjunction with settings in the BootVerificationProgram subkey. These are mutually exclusive methods.

You might also want a good system startup to depend on whether a specific service or driver loads. For example, for a server you can program the Boot Loader to choose the LastKnownGood control set if the Server service doesn't start on the computer.

To change system startup to depend on a service or driver

1. Select the subkey for the service under the following Registry path:

HKEY_LOCAL_MACHINE\System
\CurrentControlSet
\Services
\Servicename

Servicename can be any service you want successful system startup to depend on.

2. Double-click the service's ErrorControl entry, then change its value to 0x2 (which specifies to switch to LastKnownGood if the service does not start).

On rare occasions, you might want to change the ErrorControl value to 0x3 (which specifies to stop the attempted startup if the service does not start); however, this ErrorControl value is usually reserved for critical services such as file system drivers.

3. To put the new values into effect, close Registry Editor, shut down the system, and restart the computer.

4. If you do not get the intended effect, restart the computer and manually select the LastKnownGood control set as described in "Starting a System with Configuration Problems," earlier in this chapter. (All changes in the last session will be discarded.)