This article was previously published under Q281820
This article has been archived. It is offered "as is" and will no longer be updated.
You typically use RunOnce entries to open applications one-time only, either when a system startup occurs or when a user logs on, depending on where the RunOnce entry is added in the registry.For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
137367 Definition of the RunOnce Keys in the Registry
You can use RunOnce entries in device INF files to invoke external code to run after an installation completes. This article discusses the limitations of using RunOnce in device INF files.
If you use RunOnce entries in an INF file to invoke external code after an installation completes, you must restrict the usage to calling Rundll32.exe to provide a DLL file. This allows the DLLs to run during a server-side installation of a signed INF file. For example:
You should not use RunOnce to start a setup or to start other monitoring applications because RunOnce prevents the system from performing a server-side installation of your device.
During a server-side installation of a signed INF file, RunOnce is not invoked directly; rather, the device installer (SetupAPI functions) intercepts the registry entries in the INF file, and then calls the DLL directly as if invoked by the Rundll32.exe file through a RunOnce entry.
All RunOnce entries in the registry are run in the following cases:
At the end of installation through InstallFromHinfSection even in the cases where you must restart the computer.
After the default processing of DIF_INSTALLDEVICE even if you must restart the computer (with the exception of server-side processing).
After the system has been restarted.
Programs that must run once when the computer is restarted should be specified through RunOnceEx entries.
NOTE: Instead of using RunOnce entries, the preferred way is to use the coinstaller wherever possible.
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
158022 RunOnce Registry Key Runs Program at Every Startup