diff --git a/playbook/shopfloor-setup/Stage-Dispatcher.ps1 b/playbook/shopfloor-setup/Stage-Dispatcher.ps1 index 5f7e999..b9b4fde 100644 --- a/playbook/shopfloor-setup/Stage-Dispatcher.ps1 +++ b/playbook/shopfloor-setup/Stage-Dispatcher.ps1 @@ -86,6 +86,20 @@ switch ($stage) { break } + # Defensive: re-register RunOnce BEFORE calling Run-ShopfloorSetup. + # Setup chains we don't control (FormTracePak Setup.exe, eDNC MSI, + # any vendor installer that forces an immediate reboot) can cut + # the script off mid-flight. Without this, the dispatcher never + # returns from & $script and the post-call Register-NextRun never + # fires, leaving the next boot with no RunOnce + a stalled image. + # With this defensive register the next boot re-fires the same + # dispatcher, which re-reads the still-'shopfloor-setup' stage + # file, re-runs Run-ShopfloorSetup (every step is idempotent + + # detects already-installed state), and converges. Once + # Run-ShopfloorSetup returns normally we re-register again below + # before advancing to the next stage - cheap, idempotent. + Register-NextRun + # -FromDispatcher bypasses the stage-file gate at the top of # Run-ShopfloorSetup (which would otherwise see the stage file # and exit immediately thinking it should defer to us).