Rebooting During Post-Setup

davebold370

New Member
I would like to rename and reboot the computer during post setup and then continue back to post-setup. I have a batch script that will ask the user for the new computer name then change the name. However, the name change will not take effect until the system reboots. The next program I want it to install uses the hostname to setup itself up. So my question is, the post-setup restart after a forced reboot? If not, then how would I get it to do so? I'm trying to avoid using unneeded license.
 
Should be fine, try adding something like this at the end of the post-setup page:
- add your batch file to the post-setup page, make sure it's below the reboot command, so it's just copied, not actually ran
- add reg entry for Runonce with your post-reboot batch file location
- execute shutdown restart command (shutdown -r -t 0), before the batch file, after the reg entry was added

Btw today will release some fixes around post-setup page ordering, so you may want to wait for that one.
And judging by this thread, you may need to split the shutdown command in another batch file and call that one.
 
Thank you.
The registry edit, should that sit inside a batch or should that just be a reg command? then what I want to come after?
 
Got in the mood to explain it in more details, if you haven't solved it already.

You can add the reg add command directly, which calls your post-reboot script from runonce.

This is how post-setup should look like ordered:
- reg add runonce batch (will be located in C:\Windows\Setup\Scripts\)
- shutdown -r -t 0
- mybatch.cmd (this is here just to copy the file to the above location, but do not execute it, way to ensure that is to have the reboot command above)

Regarding the reg add:
If you want to execute on user logon:
REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /V "MyBatch" /t REG_SZ /F /D "C:\Windows\Setup\Scripts\mybatch.cmd"
Same for machine runonce, if you want to execute before users log on, HKLM

Your batch will be executed by the machine from the RunOnce reg key, and hopefully your batch file if it was correctly specified.
You can test that live from CMD before testing in a VM or for real on reinstall.
Don't forget to reboot the main set, because otherwise it will delete the files from Scripts folder, as a self-cleanup.

Let me know how it goes or if you have more questions.
Thanks.
 
I was finally about to test everything out, however, the prompt for name change never occurred. Do I need to switch the program to audit mode? The system rebooted the 3 times I told it to.
 
Back
Top