Microsoft KB Archive/281820

{|
 * width="100%"|

INFO: Specifying RunOnce in Device INF Files

 * }

Q281820

-

The information in this article applies to:


 * Microsoft Windows 2000 Driver Development Kit (DDK)

-

SUMMARY
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:

"Q137367 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.

MORE INFORMATION
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:

[DeviceInstall.RunOnce.AddReg] HKLM,%RunOnce%,&quot;Name_Of_The_Entry&quot;,,&quot;rundll32.exe Name_Of_The_dll,Entry_Point_In_To_The_DLL Argument1, Argument2,..etc.&quot; 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:


 * 1) At the end of installation through InstallFromHinfSection even in the cases where you must restart the computer.
 * 2) After the default processing of DIF_INSTALLDEVICE even if you must restart the computer (with the exception of server-side processing).
 * 3) 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.