Fix Windows 10 In-Place Upgrade Task Sequence infinity restart loop

By | July 10, 2017

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!!!

  1. Make a Dart 10 ISO file, upload it to somewhere.
  2. 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.

  3. 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.
  4. 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
  5. Restart the problem machine.
  6. 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.

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

to this:

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? 🙂

More information:
https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-a-custom-script-to-windows-setup

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.”

 

 

2 thoughts on “Fix Windows 10 In-Place Upgrade Task Sequence infinity restart loop

  1. Martin

    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.

    Reply
    1. Zeng Yinghua (Sandy) Post author

      Hi Martin, thanks for more tips about this. Indeed, can be many causes. Reading logs and status messages helped a lot for troubleshooting.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *