none
Setting a FinishAction for an MDT upgrade is problematic - here's how to fix it RRS feed

  • Question

  • If you set FinishAction to customize how MDT completes when running an upgrade task sequence (to upgrade, say, from 1703 to 1709), your system will end up in a bad state. Why?

    MDT finishes the upgrade task sequence by utilizing the SetupComplete.cmd functionality described here. The docs note that:

    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.

    MDT will process the FinishAction regularly, which will reboot/shutdown the system out from underneath SetupComplete.cmd. Indeed it leaves things in a weird state, leading to, at the least, an unexpected restart the next time the computer turns on.

    You can fix MDT (use MDT 8450, previous versions have other upgrade issues) by changing the code in LiteTouch.wsf under the following comment

    'Process the finish action

    to the following, which uses the supported SetupShutdownRequired registry keys to properly invoke a shutdown/restart when running SetupComplete.cmd:

    ' Process the finish action
    If oEnv("_MDTUpgrade") = "TRUE" then
        Select Case UCase(sFinishAction)
        Case "SHUTDOWN"
            oShell.RegWrite "HKLM\SYSTEM\Setup\SetupShutdownRequired", 0, "REG_DWORD"
        Case "RESTART", "REBOOT"
            oShell.RegWrite "HKLM\SYSTEM\Setup\SetupShutdownRequired", 1, "REG_DWORD"
        End Select
    else
        Select Case UCase(sFinishAction)
        Case "SHUTDOWN"
            Shutdown
        Case "RESTART", "REBOOT"
            Reboot
        Case "LOGOFF"
            Logoff
        End Select
    end if



    Friday, January 12, 2018 11:19 PM

All replies

  • I apply your solution but issue is the same.

    Curious situation, deploument summary say all correct but behind setupcomplete.cmd window is running.

    In smsts.log can see an error that couldn´t empty some folders. I don´t know if this could be the problem.

    Monday, March 26, 2018 7:54 AM
  • Not sure about the can't empty folder errors. Did you make sure to use MDT 8450?

    Probably the first thing to troubleshoot is to try with 8450 and a new clean (except for the modification above) upgrade sequence applied to a clean windows 10 install, and see if that works for you.

    Monday, March 26, 2018 7:10 PM
  • Hi,

    Yes, I´m sure is MDT 8450.

    I tried with a new clean upgrade sequence. If I force close "setupcomplete.cmd" window after restart can see in setupcomplete.cmd that all instructions was execute.

    But I don´t undestand why command aren´t close automatically.

    Wednesday, April 4, 2018 6:15 AM
  • I'm not sure what might be going on to cause setupcomplete.cmd to not close. Any chance you can post a screenshot? What are your source and upgrade versions of windows (e.g. 1607 to 1703, 1703 to 1709, etc.)?
    Wednesday, April 4, 2018 2:10 PM
  • Sorry, I could not answer before. Update In-Place is W7 to W10 1709.

    I try repeat process and give you more information.

    The situation is all task is complete, summary Window inform that no errors but behind can see "setupcomplete.cmd" window. Mouse not run but with keyboard tab key can move to Accept and process finish.

    In setupcomplete.log can see command results. I try copy log.

    Tuesday, April 10, 2018 9:53 AM
  • This is "Setupcomplete.log" content:

    La operaci¢n se complet¢ correctamente.

    La operaci¢n se complet¢ correctamente.

    La operaci¢n se complet¢ correctamente.

    10/04/2018-11:35:57,71 Registered Setupcomplete.cmd in registry
    10/04/2018-11:57:38,35 ERRORLEVEL = -2147021886 
    10/04/2018-11:57:38,35 LiteTouch.wsf requested reboot
    10/04/2018-11:57:38,35 Rebooting now
    La operaci¢n se complet¢ correctamente.

    La operaci¢n se complet¢ correctamente.

    La operaci¢n se complet¢ correctamente.

    La operaci¢n se complet¢ correctamente.

    10/04/2018-12:01:24,34 Registered Setupcomplete.cmd in registry
    10/04/2018-12:04:51,75 ERRORLEVEL = -2147021886 
    10/04/2018-12:04:51,75 LiteTouch.wsf requested reboot
    10/04/2018-12:04:51,75 Rebooting now
    La operaci¢n se complet¢ correctamente.

    La operaci¢n se complet¢ correctamente.

    La operaci¢n se complet¢ correctamente.

    La operaci¢n se complet¢ correctamente.

    10/04/2018-12:05:27,66 Registered Setupcomplete.cmd in registry
    10/04/2018-12:09:25,32 ERRORLEVEL = 0 
    10/04/2018-12:09:25,32 LiteTouch.wsf did not request reboot, resetting registry
    La operaci¢n se complet¢ correctamente.

    La operaci¢n se complet¢ correctamente.

    This is summary window with setupcomplete.cmd behind:

    Tuesday, April 10, 2018 10:13 AM
  • The fact that the window stays open is quite bizarre. I'm guessing that SetupComplete.cmd is hanging for some reason, and the quickest way to find out where is to edit SetupComplete.cmd by adding echo statements at the beginning and after each line of code, e.g.,

    echo 1
    :: Workaround for incorrectly-registered TS environment
    reg delete HKCR\Microsoft.SMS.TSEnvironment /f > nul 2>&1
    echo 2
    set _MDTUpgrade=TRUE
    echo 3

    then see how much is echo'd in the command window that won't close. That should let you know what line SetupComplete.cmd is hanging on, and is the next step to figuring this out.

    Wednesday, April 11, 2018 7:31 PM
  • I think is a good idea.

    First of all I try explain how understand setupcomplete.cmd script.

    In line:

    for %%d in (c d e f g h i j k l m n o p q r s t u v w x y z) do if exist %%d:\MININT\Scripts\LiteTouch.wsf (wscript.exe %%d:\MININT\Scripts\LiteTouch.wsf )

    I suppose script find MININT folder. If exist execute I think execute:

    IF %ERRORLEVEL% EQU -2147021886 ....

    If don´t exist execute else commands.

    Well, script always have -2147021886. Is it posible that MINIT folder don´t delete never and only continue if I close setupcomplete.cmd script?

    Thursday, April 12, 2018 7:14 AM
  • The script looks in every local drive for minint\scripts\litetouch.wsf. If found it runs it and then uses the%errorlevel% after running to either cause a restart (which will lead us back into setupcomplete.cmd after the restart) or to finish running setupcomplete.cmd

    The fact that the Deployment Summary window is open in your screenshot suggests that setupcomplete.cmd is currently executing LiteTouch.wsf, as I'm pretty certain the DeploymentSummary window is part of LiteTouch.wsf. If you click "Finish" on the Deployment Summary window, what happens? Does SetupComplete.cmd go away? If so, I think this is just a minor cosmetic issue of the SetupComplete cmd window being visible, and can be ignored. Don't close it, but instead click Finish on the Deployment Summary dialog.

    Thursday, April 12, 2018 2:10 PM
  • My suspicions are that setupcomplete.cmd cannot finish because something cannot erase MININT folder. Also I found error to erase this folder because some file was in use. I know that I can validate "Finish" button using keyboard tab key but I need build operation documents and I prefer they use mouse, how they do habitually. Thanks for all.
    Thursday, April 19, 2018 11:21 AM