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

Windows 2000 provides for the subject functionality with the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx 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:\Windows\RunOnceEx.err file if errors occur. 
0x00000020 Create a C:\Windows\RunOnceEx.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

"Title"="The Status dialogue won't be displayed because of Flags."

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

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.