Solved reboot after setupcomplete


mkmaddin

New member
Local time
11:22 PM
Posts
6
OS
W10, W11, Debian 12, MacOS 15, Ubuntu 22.04.5 LTS
Hey,

during my setupcomplete.cmd I am performing some windows updates etc. (stuff which requires a restart).
Microsoft clearly states not to include a reboot command within setupcomplete.cmd as the windows install process might be interrupted.

So what are my options to automatically trigger a restart as soon as windows install process is complete?

Current idea would be within setupcomplete.cmd to start a separated, not waited powesrshell which checks if windeploy process is still running and if not fires a shutdown /r /t 60

different ideas with benefits?
 
Windows Build/Version
10.0.26100.X

My Computer My Computer

At a glance

W10, W11, Debian 12, MacOS 15, Ubuntu 22.04.5...
OS
W10, W11, Debian 12, MacOS 15, Ubuntu 22.04.5 LTS
The problem is really simple, unlike an unattended file in the "specialize" pass where you can have commands that require a reboot -- SetupComplete.cmd is a script that's only called once. If you reboot in the middle of the script, there's no way for Windows to resume execution inside the script.

For example:
Task 1
Task 2
shutdown /r /t 60
Task 3
Task 4

Windows doesn't return to Task 3 after a reboot. But this does work:
Task 1
Task 2 some /norestart flag
Task 3
Task 4 /norestart
shutdown /r /t 60

While technically MS frowns on this, it works because the reboot will loop you back to the first logon screen.
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
thanks for your reply

Are you sure a "hard restart" without waiting for windows install to complete does not keep any leftovers?

Looking into my test it seems like windeploy.exe is running ~ 30 sec. after setupcomplete.cmd was finished. That seems like a lot of time for cleanup to me ;)
 

My Computer My Computer

At a glance

W10, W11, Debian 12, MacOS 15, Ubuntu 22.04.5...
OS
W10, W11, Debian 12, MacOS 15, Ubuntu 22.04.5 LTS
If you trim /t to something shorter like 3-5 seconds, it's enough time to perform most cleanup work.

Task 1
Task 2
Task 3
Task 4
shutdown /r /t 5
del /s /q folder\*.* /y

What you want to avoid is waiting too long, because it will interrupt new user provisioning. I haven't seen too many examples of corruption, but still.
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
Back
Top Bottom