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.
- 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
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.
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:
If you use these scripts, and you make a mistake, or it returns a non-zero exit code, you can expect bad things in the way of failed upgrades. Depending on which script fails, you'll see exit codes like this:
- MOSETUP_E_PREINSTALL_SCRIPT_FAILED A preinstall script failed to execute or returned an error.
- MOSETUP_E_PRECOMMIT_SCRIPT_FAILED A pre-commit script failed to execute or returned an error.
- MOSETUP_E_FAILURE_SCRIPT_FAILED A failure script failed to execute or returned an error.
- MOSETUP_E_SCRIPT_TIMEOUT A script exceeded the timeout limit.
Now if you want to setup a process for auto remediation, perhaps the eventhandler log. [MS Docs]