Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RunOnce command executed from SetupComplete.cmd after SysPrep doesn't work, while it works fine from Windows

OS: Windows 7 Embedded 64-bit (Template used: Application compatibility)

I'm trying to run another script (SetupComplete2.cmd) after SetupComplete.cmd runs and the computer reboots.

I added this line in the SetupComplete.cmd:

REG ADD "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v Setup /t REG_SZ /d "cmd.exe /C C:\Windows\Setup\Scripts\SetupComplete2.cmd" /f

This command works great from Windows, I tested it several times, but it doesn't work when ran from SetupComplete.cmd for some reason...

Can anyone tell me what am I missing?

Or, can anyone here suggest a way to run another script, just once, after the initial setup reboot?

I need to run another script beacuse I am renaming the computer in the SetupComplete.cmd script, and I am auto-installing applications in SetupComplete2.cmd that depend on the new computer name, I can't rename the computer and install applications right after, since the computer rename didn't take full effect until a reboot took place, am I wrong?

like image 391
ToastMan Avatar asked Aug 04 '26 18:08

ToastMan


1 Answers

Several links seem to imply that it's more than just a string in the command. Have a look at this: http://technet.microsoft.com/en-us/library/dd346765.aspx

Also consider the context. HKLM entries will run in the context of the Local\System account. HKCU entries will run in the context of the user. Which do you require?

like image 71
0xG Avatar answered Aug 11 '26 17:08

0xG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!