Creating a Custom Startup Verification Program

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

This basic standard for verifying system startup will suit the needs for 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 might want to redefine startup validation for a server where, normally, no one logs on or where 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 SQL server responds to a request. To do this, you might write a program that queries the SQL server and checks the response. If the response is not as expected, the program can call the NotifyBootConfigStatus() function with FALSE, causing the system to restart using the LastKnownGood control set. Or, the program might cause the system to run without saving the current configuration as the LastKnownGood control. Conversely, if the SQL server responds as expected, the program can call the NotifyBootConfigStatus() function with TRUE, causing the current configuration to be saved 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 BootVerificationProgram 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 this value is 0, it disables the automatic startup acceptance that happens 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, where the computer doesn't usually interact directly with users and you therefore don't 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 service program, BOOTVRFY.EXE, that is supplied with Windows NT. In this case, the remote computer accepts the system startup by starting the BOOTVRFY.EXE service. You can also write your own verification service that 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 key 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 "BootVerification Service Entries" in Chapter 14, "Registry Value Entries."

  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 BootVerification 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 BootVerification service in conjunction with settings in the BootVerificationProgram key. 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 might want to cause 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 upon which you want successful system startup to depend.

  2. Double-click the service's ErrorControl entry, and then specify a new value of 2 (to switch to LastKnownGood if the service doesn't start).

    On a few rare occasions, you might want to specify a value of 3 (to fail the attempted startup if the service doesn't start); however, this ErrorControl value is usually reserved for critical services such as file system drivers.

  3. For the new values to take 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 choose 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.