Run Registry

Question:

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.

Answer:

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:

HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionRunService(Once)

– As soon as Windows enters 32-bit mode, these applications/services are started – these are running prior to the logon script, or logon box

HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionRun(Once)

– run after a user logs on, after the logon script finishes, but before the desktop is fully loaded in.

HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRun(Once)

– 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, "SoftwareMicrosoftWindowsCurrentVersionRunOnce[wbfile]","c:whateverwbapp.exe parm1 parm2 ...")

On the next boot, c:whateverwbapp.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:

;==============snip====================
; wbapp.wbt
if param0 then goto param1

:Start
...
:Reboot ; come back to here after reboot
;==============snip====================

and put the app into RunOnce with the parameter “Reboot”.

More …

RunOnce is a registry key at…

 HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRunOnce

If you write a script like:

key="SOFTWAREMicrosoftWindowsCurrentVersionRunOnce[mystuff]"
RegSetValue(@REGMACHINE,key,"notepad.exe")

and restart windows it ought to:

  1. Run notepad.exe.
  2. Remove the registry entry for you.

Source:

http://techsupt.winbatch.com/TS/T000001029F22.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s