An explanation of, and the relationship between the
Run, RunOnce, RunServices, RunServicesOnce and Startup
Registry keys


Many times we have been asked how these keys effect the operation of Windows, when they are loaded and in what order. The following information should provide you with a better understanding of these registry keys, their relationship to each other and to the Windows Startup folder.

These references apply to:

There are seven Run keys in the registry that enable programs to be run automatically:

  1. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
  2. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
  3. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
  4. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
  5. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices
  6. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce
  7. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ RunOnce\Setup

*Note: The RunOnce key is not supported in Windows NT version 3.51.

Key Execution

Keys 1-4 are run each time a new user logs in.

Keys 5-6 are run in the background when the logon dialog box first appears, or at this stage of the boot process if there is no logon. These keys are for background services such as remote registry service and are run only once per boot.

Key 7 is run as part of Setup's first-boot activities, or after you use the Add/Remove Programs Wizard.

Under each of these keys is a series of values. The values are used to allow multiple sub-entries to exist without one overwriting another.

The data value for a particular key is a command line. By default, Run keys are ignored in Safe mode. For keys 3-4, the value name can be prefixed with an exclamation point to defer deletion of the value until after the command has been completed.

For keys 3, 4, and 6, the value is deleted before the command line is run unless overridden as noted above. As a result, if a RunOnce operation fails to run properly, the component that failed will not be asked to run again the next time you start the computer.

Key 7 is used only by Setup. This key displays the progress dialog box as the keys are run one at a time. For key 7, the name of the value is the name that is displayed in the dialog box.

Key Load Order:

Under Windows 95 and Windows 98, where all keys are supported, the keys are loaded in the following order:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce 
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices<Logon Prompt> 
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce 
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run 
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run StartUp Folder 
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce 

With the exception of the HKEY_LOCAL_MACHINE\...\RunOnce key, all keys and their entries are loaded asynchronously. Therefore, all entries in the RunServices and RunServicesOnce keys can potentially run at the same time.

Entries in the HKEY_LOCAL_MACHINE\...\RunOnce key are loaded synchronously in the order they were added to the RunOnce key. Note: This is not necessarily the order in which these entries are displayed by the Registry Editor.

Since the HKEY_LOCAL_MACHINE\...\RunOnce key is loaded synchronously, all of its entries must finish loading before the HKEY_LOCAL_MACHINE\...\Run, HKEY_CURRENT_USER\...\Run, HKEY_CURRENT_USER\...\RunOnce, and Startup Folder entries can be loaded.

The RunServicesOnce and RunServices keys are loaded before the user logs into Windows 9x. Because these two keys run asynchronously with the Logon dialog box, they can continue to run after the user has logged on. However, since HKEY_LOCAL_MACHINE\...\RunOnce must load synchronously, its entries will not begin loading until after the RunServicesOnce and RunServices keys have finished loading.

Because of different system configurations, such as that of a computer that has been configured to automatically log on, any application that is dependant upon other applications that are executed under these keys being or having completed, must be prepared to wait until these applications have completed fully. Other than this exception, the above applies to Windows NT 4.0 and Windows 2000 as well.

The RunOnceEx Registry Key

Microsoft Windows 98 and Microsoft Windows Millennium Edition only!

RunOnceEx has the following features:

Copyright ©1995-2000 DEW Associates Corporation. All rights reserved.