Post-install problem with $OEM$\...\SetupComplete.cmd

Ben-J

New Member
Messages
3
Reaction score
0
Hello,

I can't force a reboot of the workstation at the end of the system installation using SetupComplete.cmd.

Sample test:

@ECHO OFF
CD "%TEMP%"&CLS&@TITLE Post-Installation Tasks
mkdir c:\TEMP & echo. > c:\TEMP\test.txt
CD C:\Windows\System32 & shutdown.exe /r /t 0 /f
del /q /f "%WINDIR%\Setup\ScriptsNTLCompName.vbs"
del /q /f "%0"

The folder and txt are created but no reboot afterwards. The cmd runs correctly but does not take the reboot. Any ideas? Thank you.

For your information, I've already tried :
  1. shutdown.exe /r /t 0 /f
  2. CD C:\Windows\System32 & shutdown.exe /r /t 0 /f
  3. C:\Windows\System32\shutdown.exe /r /t 0 /f

Ben
 
Last edited:
Is this PC joined to a domain? I've never had a problem with shutdown from SetupComplete.cmd, but your script references NTLCompName.vbs (which is normally used to rename hosts for use with a domain).
 
Yes, my PC is attached to a domain, but I don't see what that has to do with anything.

The SetupComplete.cmd plays well because it creates the temp folder with the txt but the shutdown is not taken into account. I have the same problem if I run it with another script:

@ECHO OFF
CD "%TEMP%"&CLS&@TITLE Post-Installation Tasks
call %WINDIR%\Setup\Files\Reboot.cmd
rd /q /s "%WINDIR%\Setup\Files"
del /q /f "%WINDIR%\Setup\Scripts\NTLCompName.vbs"
del /q /f "%0"
 
What happens with:
shutdown /r /t 1 /f 2>&1 >> C:\temp\log.txt
 
I'm not sure if it is you case, but there are some operations that need to be executed at user level, which is AFTER setupcomplete.cmd runs. one infamous example was spotify installer, is simply did NOT allow an installation for all users, but lately, I use it for WindowsUpdateBlocker and OOShutUp10 Automation.

So IF your task is user based, you can try with a RunOnce registry enter pointing to a batch file, and a 'add to run once to registry' line before the end of said file and reboot, where it adds a 'self-deletion' of the batch file to the RunOnce after the reboot. If its a single line command, you can also add directly to NTLite as a Run-once entry.

Regfile Example
Code:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]
"AutoSetup"="C:\\Setup\\Setup.cmd"

Batch Example (Deletes everything on Desktop and then Copies the contents of "C:\Setup\Desktop" there)
Code:
DEL /F /S /Q %USERPROFILE%\Desktop\*.*
DEL /F /S /Q %PUBLIC%\Desktop\*.*
XCopy /S /Y /Q "%SYSTEMDRIVE%\Setup\Desktop\*.*" "%USERPROFILE%\Desktop\"
Reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v "DeleteSetupFolder" /t REG_SZ /d "cmd /c \"RD /S /Q %SYSTEMDRIVE%\Setup"" /f
shutdown /r /f /t 0
 
Back
Top