We successfully did Windows 10 In-Place Upgrade for hundreds machines, but few of them went into infinity restart loop at the end.
Troubleshoot wasn’t easy, especially do it remotely. Yeah, you are right, how to troubleshoot and fix a computer that reboot itself and also has bitlocker and bitlocker PIN? Sounds mission impossible, but WE DID IT!!!
- Make a Dart 10 ISO file, upload it to somewhere.
- Let’s hope you have the bitlocker key for this problem machine, because you need it to do the following steps. Advise user or other IT support do the following steps:
1) Download the Dart 10 ISO file
2) Make a Dart 10 bootable usb stick.
3) Shut down the problem machine and boot it up from usb stick.
4) Open remote connection tool, give you the ip address, ticket number, and port number.
- Open up Dart remote connection tool from your machine, use the information you got (ip address, ticket number, and port number) connect to the problem machine.
- Run regedit in the problem machine, change HKEY_LOCAL_MACHINE\SYSTEM\Setup!StepType to 0 and change HKEY_LOCAL_MACHINE\SYSTEM\Setup!CmdLine to empty
- Restart the problem machine.
- Problem solved.
So, what cause the infinity restart loop? Reason is HKEY_LOCAL_MACHINE\SYSTEM\Setup!StepType was set to 2, and HKEY_LOCAL_MACHINE\SYSTEM\Setup!CmdLine was set to run C:\Windows\SMSTSPostUpgrade\SetupComplete.cmd, but C:\Windows\SMSTSPostUpgrade folder was removed. Machine was trying to run SetupComplete.cmd that doesn’t exited anymore, so it went into a restart loop.
Let’s take a look in smsts.log, when machine starts to run “Upgrade Operating System”, it use “%WINDIR%\CCM\SetupCompleteTemplate.cmd” as sample to create “%WINDIR%\SMSTSPostUpgrade\setupcomplete.cmd”, then this cmd file goes to “C:\$Windows.~BT\Sources\Scripts\setupcomplete.cmd”. After OSDUpgradeWindows is done, it goes to “%WINDIR%\Setup\Scripts\setupcomplete.cmd”
Here is the original script, and as you can see, the script create HKLM\System\Setup!CmdLine registry to run “%WINDIR%\SMSTSPostUpgrade\setupcomplete.cmd”, if error level is not -2147021886, registry should be reset.
I don’t know what really happened to those few machines that end up infinity restart loop, seems they finished all the TS steps, then rebooted for some reason without returning error code to the setupcomplete.cmd script, or the script has not finish to the end, so registry was not reset, some how task sequence manager think TS is finished and cleaned up the C:\Windows\SMSTSPostUpgrade folder, without checking if restart registry is reset.
@ECHO OFF REM SCCMClientPath should be set before we get here REM This script is written by ConfigMgr Task Sequence Upgrade Operating System action REM SetupComplete.cmd -- Upgrade Complete, calling TSMBootstrap to resume task sequence echo %DATE%-%TIME% Entering setupcomplete.cmd >> %WINDIR%\setupcomplete.log echo %DATE%-%TIME% Setting env var _SMSTSSetupRollback=FALSE >> %WINDIR%\setupcomplete.log set _SMSTSSetupRollback=FALSE echo %DATE%-%TIME% Setting registry to resume task sequence after reboot >> %WINDIR%\setupcomplete.log reg add "HKEY_LOCAL_MACHINE\SYSTEM\Setup" /v SetupType /t REG_DWORD /d 2 /f reg add "HKEY_LOCAL_MACHINE\SYSTEM\Setup" /v CmdLine /t REG_SZ /d "%WINDIR%\SMSTSPostUpgrade\setupcomplete.cmd" /f echo %DATE%-%TIME% Running %SCCMClientPath%\TSMBootstrap.exe to resume task sequence >> %WINDIR%\setupcomplete.log %SCCMClientPath%\TSMBootstrap.exe /env:Gina /configpath:%_SMSTSMDataPath% /bootcount:2 /reloadenv IF %ERRORLEVEL% EQU -2147021886 ( echo %DATE%-%TIME% ERRORLEVEL = %ERRORLEVEL% >> %WINDIR%\setupcomplete.log echo %DATE%-%TIME% TSMBootstrap requested reboot >> %WINDIR%\setupcomplete.log echo %DATE%-%TIME% Rebooting now >> %WINDIR%\setupcomplete.log reg add "HKEY_LOCAL_MACHINE\SYSTEM\Setup" /v SetupShutdownRequired /t REG_DWORD /d 1 /f ) else ( echo %DATE%-%TIME% ERRORLEVEL = %ERRORLEVEL% >> %WINDIR%\setupcomplete.log echo %DATE%-%TIME% TSMBootstrap did not request reboot, resetting registry >> %WINDIR%\setupcomplete.log reg add "HKEY_LOCAL_MACHINE\SYSTEM\Setup" /v SetupType /t REG_DWORD /d 0 /f reg add "HKEY_LOCAL_MACHINE\SYSTEM\Setup" /v CmdLine /t REG_SZ /d "" /f ) echo %DATE%-%TIME% Exiting setupcomplete.cmd >> %WINDIR%\setupcomplete.log set SCCMClientPath=
So how can prevent this happen again? I don’t have fully supported and 100% correct answers for you.
I have been testing in this whole weekend, I added a last step to run a cmd file, inside cmd file I put “shutdown.exe /r /f /t 0”, and that makes the infinity restart loop, this is for testing the unexpected restart, so that I can put my test machine to infinity restart loop situation, you should never do that in production.
Then I modified “%WINDIR%\CCM\SetupCompleteTemplate.cmd”. I changed this line
reg add "HKEY_LOCAL_MACHINE\SYSTEM\Setup" /v CmdLine /t REG_SZ /d "%WINDIR%\SMSTSPostUpgrade\setupcomplete.cmd" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\Setup" /v CmdLine /t REG_SZ /d "%WINDIR%\Setup\Scripts\setupcomplete.cmd" /f
Then run the same TS again, I see machine is using C:\Windows\Setup\Scripts\setupcomplete.cmd to run Post-Installation steps, and it didn’t make the infinity restart loop.
Because I cannot be 100% sure in Post-Installation steps, will all the steps runs correctly in every single machines that we deployed, or will machine restarted unexpectedly during installation, I think it is better use “%WINDIR%\Setup\Scripts\setupcomplete.cmd” than this temporary “%WINDIR%\SMSTSPostUpgrade\setupcomplete.cmd”. And I added last step in my TS to reset these registries.
Just keep me wonder, why ConfigMgr clean up %WINDIR%\SMSTSPostUpgrade folder before it checks if HKLM\System\Setup!SetupType and HKLM\System\Setup!CmdLine is reset? 🙂
“Warning You cannot reboot the system and resume running SetupComplete.cmd. You should not reboot the system by adding a command such as shutdown -r. This will put the system in a bad state.”
We had the same issue. Sometimes boot loop, sometimes TS just stuck on SetupComplete.cmd. If you force restart at this stage->boot loop.
What fixed it in our case, was to recreate the upgrade TS from scratch using the console’s TS wizard. The TS we used previously was originally made with SCCM 1606, and the server had gone through 1610 and 1702 upgrades. Maybe the TS had become corrupted along the way, maybe it used the wrong/old setupcomplete.cmd script. Anyway, our success rate with the new TS is now 100%.
With 1606 and upgrading Win7->10 1607, we used to get boot loops caused by antivirus software Trend Officescan, if it was not removed prior to upgrade. So there can be many causes, it seems.
Hi Martin, thanks for more tips about this. Indeed, can be many causes. Reading logs and status messages helped a lot for troubleshooting.
Would editing the “%WINDIR%\CCM\SetupCompleteTemplate.cmd” in the beginning of the TS with the edit you suggested also work? Since it is the file used to create the others, shouldn’t that work?
I seems remember I tried edit this file in TS and I failed, but I am not 100% sure and maybe I did it wrong :).
I created SetupCompleteTemplate.cmd file as package, and copy that to %WINDIR%\CCM folder in my TS, using this in our production, so far working still.
When you say “Reset these registries,” can you elaborate?
“Reset” means it should run these command if there is no error, based on the original script:
echo %DATE%-%TIME% TSMBootstrap did not request reboot, resetting registry >> %WINDIR%\setupcomplete.log
reg add “HKEY_LOCAL_MACHINE\SYSTEM\Setup” /v SetupType /t REG_DWORD /d 0 /f
reg add “HKEY_LOCAL_MACHINE\SYSTEM\Setup” /v CmdLine /t REG_SZ /d “” /f
Which means, it should set the SetupType value to 0, and clear the CmdLine value.
Hi Sandy, I’m having the same problem, but I’m not totally clear on how to implement your workaround in my TS. Do you think you could post some screenshots and a little deeper explanation of exactly how to incorporate the workaround into an upgrade TS? I would greatly appreciate it.
Hello Philip, Gary has wrote an excellent log post about how to modify SetupComplete.cmd in TS, you can find it from here https://garytown.com/customize-setupcomplete
Thanks Sandy for the Article,
I deployed windows 1803 upgrade on to 1607 machine. After the upgrade it completes all the steps in the TS. after reboot i can see dell logo and it resatrts again and dell logo. its continuous. Following the above articles fix this?
Hello, I can’t tell you that my article will fix your issue, it’s just my experience that fix the issue that I had in our scenario. Every restart loop might have it’s own reason, you will need to read logs and figured out what cause it. It can be also driver issues, bios is out dated, or even application can cause it.