Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase

Registry Run Keys

Keywords: registry regedit Run	RunOnce 


Is there a way to have a winbatch script initiate a reboot using the IntControl parm and have control returned to the script AFTER the machine boots?

Reason being, I'm using WinBatch to install a product and I need to do a reboot after installation before beginning the configuration procedures, also via WinBatch.


There are three locations in the registry from which you can launch an application after a reboot:

Startup Sequence:

You can start various applications or events at controlled time in Windows, by dictating when the 32-bit process should be activated. Here is the areas in which you should assign tasks, based on when you want them to start:

- As soon as Windows enters 32-bit mode, these applications/services are started - these are running prior to the logon script, or logon box
- run after a user logs on, after the logon script finishes, but before the desktop is fully loaded in.
- once the logon script is finished, and Windows has loaded the desktop STARTUP folder from the Start Menu - last place Windows starts programs from

Here's an example (for both Windows 95 and NT):

RegSetValue(@REGMACHINE, "Software\Microsoft\Windows\CurrentVersion\RunOnce[wbfile]","c:\whatever\wbapp.exe parm1 parm2 ...")
On the next boot, c:\whatever\wbapp.exe parm 1 ... will be run.

I used a parameter and had wbapp.exe work so that if parm1 existed, to do a goto to that value, eg:

; wbapp.wbt
if param0 then goto param1

:Reboot ; come back to here after reboot
and put the app into RunOnce with the parameter "Reboot".

More ...

RunOnce is a registry key at...
If you write a script like:
and restart windows it ought to:
  1. Run notepad.exe.
  2. Remove the registry entry for you.


How would I set the Runonce key to launch more than one application, say if another program has already written to that key? Any ideas?


  1. Whether you use the @REGCURRENT KEY or @REGMACHINE key depends on whether you want to run that stuff for the next time windows is started, or the next time a particular user logs in.

    We'll assume the @regmachine here:



I have a DUN Program I wrote with WB 97D and one of the parts to the program is that it adds an entry into:
What this does is it will run a recovery compiled wbt if Windows was shutdown etc before the original program had a chance to restore certain settings. For some reason it works fine under Run, but not under Runonce, or RunonceServices.

Any thoughts? BTW on some PCs it will run under Runonce, mainly slower PCs below 166MHZ Pentium.


Ummm. Are you trying to update the @REGCURRENT key? The current user might not be quite established at that point.

You might try adding a:

at the top of the script and see if that helps.

Or worse yet, have a stript with a TimeDelay in it launch the real script.

There are a lot of strange things that happen during Windows startup, so I usually put a Time delay in scripts that run at startup.

Winlogon key:

A User reported the following:

Winlogon[Userinit] allows you to kick off a script each time someone logs on without having to add an icon to the startup group or reboot the machine. Append your script onto the existing string uner NT in:

so when you logon as a new user, the script automatically will launch.
Here's additional information from Microsoft about the Run keys in the registry:
Article last modified on 09-27-1995
The information in this article applies to:
 - Microsoft Windows 95
There are seven Run keys in the registry that 
cause programs to be run automatically:
1. HKEY_LOCAL_MACHINE\Software\Microsoft\
2. HKEY_CURRENT_USER\Software\Microsoft\
3. HKEY_LOCAL_MACHINE\Software\Microsoft\
4. HKEY_CURRENT_USER\Software\Microsoft\
5. HKEY_LOCAL_MACHINE\Software\Microsoft\
6. HKEY_LOCAL_MACHINE\Software\Microsoft\
7. HKEY_LOCAL_MACHINE\Software\Microsoft\
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 subkeys. 
The subkeys are used to allow multiple sub-entries 
to exist without overwriting one another.
The value for a subkey is a command line. For 
keys 1-4, the command line can be prefixed with 
an asterisk to indicate that it should be run even 
in Safe mode. By default, Run keys are ignored in 
Safe mode. For keys 3-4, the command line can be 
prefixed with an exclamation point to defer deletion of
the subkey until after the command has been completed. 
You cannot combine the two prefixes.
For keys 3, 4, and 6, the subkey 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 when 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 subkey is the
name that is displayed in the dialog box.
KBCategory: kbsetup
KBSubcategory: win95
Additional reference words: 95
Copyright Microsoft Corporation 1995.

Article ID:   W13732
Filename:   Registry Run Keys - Run and Runonce.txt