JSI Tip 3320. How do I run a series of 'jobs' in Windows 2000, the next time a user logs on?

Jerold Schulman

January 31, 2001

2 Min Read
ITPro Today logo in a gray background | ITPro Today


Windows 2000 provides for the subject functionality with the HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRunOnceEx key.

When properly configured, RunOnceEx causes one or more 'jobs' to be run on the desktop, with user interaction, and then, Windows 2000 removes the Value Names and sub-keys.

There are two value names that can be configured at the RunOnceEx key:

Title is a string Value Name whose data value is the Status dialog box title.

Flags is a REG_DWORD data type whose values are cumulative:

0x00000000 Default, All functions are disabled. 0x00000004 Check Shell Status Verifies the shell is ready to accept OLE commands. 0x00000008 Error dialog boxes are not displayed.0x00000010 Create C:WindowsRunOnceEx.err file if errors occur. 0x00000020 Create a C:WindowsRunOnceEx.log file with the status of commands. 0x00000040 No Exception Trapping occurs when registering DLLs. 0x00000080 No Status Dialog Status dialog box is displayed while RunOnceEx runs.

Each 'job' that you define is implemented by creating a sub-key. There is no limit to the number of job that you define, which are run in sub-key alphabetical order. I use 0001, 0002, etc., but alphanumeric names are supported.

The Value Names that you define represent the work that will be performed and the data values have the following syntax:

"DllFileName|FunctionName|CommandLineArguements" or "||command parameters".

For example:

A value name of Process1, under the 0001 sub-key, might have a data value of ||MyBrowser.exe -quiet -url http://www.microsoft.com/, which would run the MyBroswer.exe program with the listed arguments. A value name of Process2, with a data value of shdocvw.dll|DllRegisterServer, under the same sub-key, would run the DllRegisterServer function in Shdocvw.dll, when MyBrowser.exe was closed.

If RunOnceEx, or any sub-key, has a Depend sub-key, its' value names list the DLLs and .ocx files that should be kept in memory while the 'job' is running.

Here is a sample configuration to open c:instructions.txt in Notepad:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRunOnceEx]
"Title"="The Status dialogue won't be displayed because ofFlags."
"Flags"=dword:00000088

[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRunOnceEx001]
"Step01"="||notepad.exe c:\instructions.txt"


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like