Customize SetupComplete.cmd and SetupRollback.cmd

Why?  Ever want to run a few tasks after upgrade, or more importantly, ensure a few things happen if the upgrade goes south and rollsback?  Why not hitch a ride on what ConfigMgr is doing natively and add a few things you need.

Supported?  Highly unlikely.  Please test, and please don’t say “Gary did it” as rationalization when someone asks why you decided to do this.

Do you do it?  Heck yes I do, in my lab.  Need to get a little more test results before implementing in Production

How do you use it?  I’m not telling! Oh wait, that’s why I’m blogging.  I modify the SetupRollback.cmd to ensure the machine is pulled out of provisioning mode when it the upgrade rolls back, and to set a registry key for our reporting, and trigger hardware inventory.

More background.
ConfigMgr has two files in the c:\windows\ccm folder that it uses:

  1. SetupCompleteTemplate.cmd
  2. SetupRollbackTemplate.cmd

During the IPU Task Sequence, the Run OS Upgrade Step does many many things (OSDUpgradeOS.exe), like place the machine into provisioning mode, compile the command line to be used with the Windows 10 Setup Engine, and more, including, what we’ve gather here today to talk about, creating the SetupComplete.cmd and SetupRollback.cmd files.

image

These files also live on your server, so if you want to modify the ones in your boot media for whatever reason, you’d do it here: %Program Files%\Microsoft Configuration Manager\OSD\bin\x64
image

Knowing this information, we can then create our own package with those files.
image
I’ve created a readme file with basic info (I tend to forget, which is why I blog and document).  I also created Append text files for each, which contains the additional information I’ve added to each of the two command files.  Why?  So the next time I update CM to the next Current Branch, I can grab the latest SetupCompleteTemplate.cmd and SetupRollbackTemplate.cmd  files and use those.  Perhaps the CM Team updated the scripts with some useful items.  This way, I can just delete the 2 I have, copy the new ones over, and append my additional code to them.

SetupRollbackTemplate.cmd: (Yellow is what I added)
image

In the In Place Upgrade Task Sequence:
image

xcopy *.cmd "%WINDIR%\CCM" /Q /Y /I

I also made a minor change in the SetupComplete.cmd, just so I could confirm this was working without having to reproduce an actual rollback.
image

And as you can see, after the upgrade, the registry key is updated, the log file is also updated.
image

OR... the NO Content Version.  I actual prefer this, as you don't have to manage a package and keep it updated.
I have 2 steps in the TS, one for each .cmd file.

SetupComplete (just creating a test key, I really don't have anything I need to do with this, as anything post upgrade I do in the TS)

SetupFallback, Update WaaS_Status Key, Pull from Provisioning Mode, Trigger HWinv

I hope you find this interesting, if not helpful.
Thanks to @MikeTerrill for showing me these files on the Server, and peeking my curiosity as I search for ways to improve the IPU process, one of which is to reduce the number of machines stuck in provisioning mode after they roll back.
Originally Posted on GARYTOWN.COM

3 thoughts on “Customize SetupComplete.cmd and SetupRollback.cmd

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.