Question

Is there any way I can reboot my computer after each component installation specified in RunOnceEx.CMD file?

I am creating a unattended setup disk for windows XP which would install some default software after installing windows on the system. I am using RunOnceEx.cmd file to define the software that needs to be installed, what I want is to reboot my the system after installation of each software.

Thanks and regards,

Was it helpful?

Solution

Yep there is. Although it's not a supported feature. I do something similar.

This might not be the the fanciest solution but it works reliably. The key is to stop the RunOnceEx process (rundll32.exe) before commencing the reboot procedure. If it's not stopped, Windows will stop all processes before shutting down in an unknown order. And if that order means killing our "Reboot" process before killing the RunOnceEx process it will continue on the next item on the RunOnceEx list before being killed (and thus aborted, which is not what we want).

The simple answer, add a reboot key that kills the RunOnceEx process and then reboots:

set %KEY%=HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
REG ADD %KEY%\009 /ve /D "Reboot.." /f
REG ADD %KEY%\009 /v 1 /D "cmd.exe /c taskkill.exe /f /im rundll32.exe & shutdown /r /t 0 /f" /f

This might leave remnant keys during next startup. So to make it look cleaner, add an instruction to remove the key manually before killing and rebooting:

set %KEY%=HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
REG ADD %KEY%\009 /ve /D "Reboot.." /f
REG ADD %KEY%\009 /v 1 /D "cmd.exe /c REG DELETE %key%\009 /va /f & taskkill.exe /f /im rundll32.exe & shutdown /r /t 0 /f" /f

Hope it helps.

Edit:

In XP you might have to use tskill instead of taskkill, but the principle is the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top