unattended-processing


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?
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?
I am trying to do the exact same thing and have the same problem. I have tried RunOnce and RunOnce/Setup, both on HKLM and HKCU and nothing seems to work. I don't understand the problem.
As a work-around, I just added my 2nd script to the Run key
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v Setup /t REG_SZ /d "cmd.exe /C C:\Windows\Setup\Scripts\SetupComplete2.cmd" /f
Then included a command in 2nd script remove itself (must be local administrator, not another account with admin rights, or you run into UAC issues)
REG DELETE HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v Setup /f
Before you generalize your system, create a local admin account (eg, sysadmin) and put a RunOnce key in its HKCU to run whatever .cmd or .bat file you want. Then in your unattend.xml file you include the section "Microsoft-Windows-Shell-Setup" in OOBE phase and use the "AutoLogon" component where you specify sysadmin, password and number of times to autologon (usually just once). I assume you already have an unattend.xml and know how to modify it.
You should also skip Machine and User OOBE experience so that initialization will run without input until it auto logs on to sysadmin and presents the user with the script. Of course you have to sysprep /generalize and capture your .wim file, etc. This is the only way I have found for interactive input during OOBE.
You may find that your script needs to elevate privilege. I think that RunOnce runs commands without admin privilege, so at a minimum the user will need to respond to an elevation prompt and your script will have to auto-elevate. Elevating batch files and command scripts is another topic and you likely already know how to do this.
According to the TechNet article ‘Add a Custom Script to Windows Setup’, “Commands in the Setupcomplete.cmd file are executed with local system privilege.
Kent England has good suggestions in his answer for how to get around this. I would add that you don’t need to create a local admin account, you can simply activate the built in administrator account and use that for the autologon.
You should also look into using the Microsoft Deployment Toolkit (MDT) for deploying Windows. Some benefits to using MDT include installing software after Windows is deployed with ‘Post Install’ task sequences, including checking WSUS or Windows Update for the latest updates. It can also manage device drivers and packages and can be used with Windows Deployment Services (WDS) to allow PXE booting to deliver your images. Windows Embedded PoSReady 7 is one of the supported operating systems for deployment.
Hope this helps,
EDIT: I just noticed the OP is old... I did not intentionally drag up an old post.

Related Links

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

Categories

HOME
shell
grok
cobalt
paraview
c99
apache-jena
depth
rsa
ms-access-2016
seo
regular-language
polling
watson-conversation
ipmitool
onedrive-api
gource
linear-algebra
null-pointer
mvc-mini-profiler
jmp
connector
spring-async
dynamically-generated
xcode-ui-testing
pic32
interbase
custom-post-type
bulletphysics
delimiter
bioinformatics
sqlpackage
vex
winpe
fstream
code-snippets
hard-drive
indy10
alphabetical
xdocreport
chef-solo
setup.py
android-softkeyboard
lpsolve
httr
optimizely
fwrite
opennms
robomongo
dotnet-httpclient
vugen
identification
singleinstance
static-cast
cvxpy
omxplayer
lrs
nikeplus-api
pushbots
blitline
concept-insights
vhosts
sciruby
xenomai
mirror
cross-join
webmatrix-3
spy++
iso-prolog
webfinger
paw
vsx
menubar
asdf
bjyauthorize
joomla3.1
dopostback
nokia-s40
google-maps-mobile
ajax-polling
tabpanel
sifr
django-piston
cuda.net
fail-fast-fail-early
sqlobject
information-management
lemmatization
cardspace

Resources

Encrypt Message