Windows 10 Upgrade - Custom Action Scripts

Custom Action Scripts were new in Windows 10 1803. My Buddy Adam wrote up a great overview, so I'm not going to replicate that hard work, please check it out at his Blog.
Also, this is going to cover the SetupRollback.cmd file CM uses to re-trigger the TS in case of a Rollback.

What I'm going to try to better explain is when the scripts come in to play, and when they run when comparing to the actual upgrade process.

NOTHING IN THIS POST IS ANYTHING YOU'D WANT TO IMPLEMENT!!! This was only for learning exactly what these scripts do, so I can then see if they are useful to me in our upgrade process.

From the Docs:

[Sarcasm] So that clears it all up, you know exactly when they run [/Sarcasm].. plus it never tells you when the failure.cmd runs.

Test Process:

  • Create a Script that:
    • Creates each of the CMD Files & PowerShell Files used in Test
    • CMD files Call PowerShell Scripts (Because batch files are the worst)
      • preinstall.cmd -> preinstall.ps1
      • precommit.cmd -> precommit.ps1
      • failure.cmd -> failure.ps1
    • PowerShell Scripts write a time stamp to Registry.
  • Script is run in the Task Sequence right before Upgrade Steps

Visually:

Creates the run and runonce folder, under both directories, the output will be identical.
under the Run \ RunOnce folders is a subfolder with a unique GUID, can be anything.
The Batch Files Call the PowerShell Scripts, that's it.

Please note, you can do everything you want inside the batch file, if you don't want to use PowerShell, you don't have to. I just find that powershell is so much more powerful and easy to write complex scripts, that I don't want to waste time writing a batch file.

PowerShell file writes a time stamp of when it ran to the registry.

I then trigger the upgrade:

preinstall.cmd happens when you start the Windows 10 Upgrade (Windows 10 Setup.exe), but before it actually starts the upgrade process.

precommit.cmd runs after the setup engine reaches 100% but before it reboots into the SafeOS

If you have a failed upgrade (has to make it first the downlevel phase, only kicks in during phase 2 and on), failure.cmd run at the same time as setuprollback.cmd which is once the the machine reverts and is back in a full OS.

Another visual of when they run:

Image modified from: https://docs.microsoft.com/en-us/windows/deployment/upgrade/troubleshoot-upgrade-errors

Testing Script:

GARYTOWN.COM

Leave a Comment

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