WinRE Manager returns one of four exit codes. Orchestration should treat them as distinct outcomes, not as success/failure booleans.
| Code | Name | Meaning |
|---|---|---|
0 |
EXIT_SUCCESS |
WinRE enabled, dedicated recovery partition healthy, state file written or already current. |
1 |
EXIT_REBOOT_REQUIRED |
A reboot is required to complete or confirm WinRE registration. Pending deployment material remains protected until verification. |
2 |
EXIT_WARNING |
The run did not achieve a clean success. Inspect the log for a deferral, constrained fallback, preservation decision or recoverable failure. Sub-cases: WinRE functional but degraded (OS-fallback); the run deferred work (Audit Mode, VMD indeterminate, offline, pre-shrink, race-detector, architecture gate, VHDX gate, intervening-anchor surplus, multi-intervening, offline LocalInputsId mismatch); a non-fatal failure is queued for retry (enable-only failure, restore /enable failure, strip-failure abort, base-WIM copy-integrity check, driver-enumeration failure, storage-applicability gate refusal, Step 3 → Step 4 pipeline gate); or the source was deliberately preserved (Foreign-With-Drivers, never-downgrade). Details in the log. |
3 |
EXIT_FATAL |
The run cannot verify an acceptable completed outcome, or a required integrity/trust/persistence check failed. Existing good routes and pending recovery material can remain; investigate the log. |
When a run’s outcome satisfies more than one condition, the priority order is:
EXIT_FATAL > EXIT_REBOOT_REQUIRED > EXIT_WARNING > EXIT_SUCCESS
EXIT_FATAL always wins. Between EXIT_REBOOT_REQUIRED and EXIT_WARNING, reboot-required wins — the machine needs to reboot either way.
In practice only two combinations are reachable through the final exit-code determination:
1 — whether or not a warning flag was also set, because the reboot is the action the operator must take either way.$Script:nonFatalWarning = $true bullet below). Returns 2.Some exit paths bypass the final determination and exit EXIT_WARNING or EXIT_FATAL directly — the v47 strip-failure abort, the v47 patch 2 base-WIM copy-integrity check, source-ownership driver-enumeration failure, the v49 storage-applicability gate refusal, the Step 3 → Step 4 pipeline gate, the Audit Mode deferral, the VMD-query-indeterminate deferral, the OS-fallback BitLocker deferral, the v45 pre-shrink deferral (including the v47 race-detector abort reason), the v47 Step 5 race-detector abort, the enable-only target-preparation failure, the enable-failure counter exit, the concurrent-instance deferral, the offline-fallback deferral, the v48 architecture-gate refusal, the v48 elevation-guard refusal, the indeterminate WinRE-status refusals, the v48 intervening-anchor surplus rejection, the v48 multi-intervening rejection, the v48 offline LocalInputsId mismatch, the v49 native-boot VHDX fail-closed gate, the v49 restore /enable failure (exit code 2), the v49 restore /setreimage failure (exit code 3), the v50 patch 3 restore WIM-deployment failure (exit code 3), the main full-update path’s WIM deployment failure (Step 6, exit code 3), the loop-breaker, and the two v50 backup-action fatal paths (destination drive letter unresolvable; insufficient destination free space). Those cases are described in the sections below.
EXIT_SUCCESS (0)The fast path found nothing to do and exited cleanly. Or the full-update path completed, WinRE reports Enabled, the state file was written, and no warning flags were set.
Also returned by -DryRun when the dry run completes without errors. Dry runs do not write a state file; they exit 0 from the deployment step.
Also returned by -Action Backup when the byte-for-byte copy completes and the sidecar backup.json is written. Backup does not rebuild, replace or reconfigure the active WinRE route, and does not write deployment state. A verified WIM copy whose sidecar write fails returns EXIT_WARNING (2); the WIM remains usable. See the warning case below and backup troubleshooting. A failed WIM copy or integrity check returns EXIT_FATAL (3).
Also returned by -Action Restore when the restore completes: the previously captured WIM is written back to the currently registered route transactionally, WinRE is re-registered, and reagentc /enable succeeds. A restore that writes the WIM but fails to re-enable WinRE exits non-zero (see EXIT_WARNING and EXIT_FATAL below) and leaves the temporary resume task registered so the operation is resumed on the next boot or within the hour.
Restore also returns 0 when the target WIM already matches the backup. That no-op leaves WinRE registration and enablement unchanged; success confirms image equivalence. Run the default Repair action if enablement or recovery-layout repair is needed.
EXIT_REBOOT_REQUIRED (1)reagentc /enable returned exit 0 but reagentc /info did not immediately report Enabled. This is a common result after a fresh registration: Windows schedules the registration to complete on the next reboot.
The script writes the state file with PendingReboot = true, records the deployed partition number and disk number so the next run knows where the WIM is, and exits with code 1.
Also returned by the pending-reboot path when the retry reagentc /enable still returns reboot-required, by the enable-only path when reagentc /enable returns reboot-required, and by the restore action when the WIM was replaced and reagentc /enable returns reboot-required after the restore.
EXIT_WARNING (2)Reached when any of the following is true at exit time:
OS-fallback. Dedicated creation actually failed and no acceptable previous/readable enabled route can be retained. With verified geometry and fully decrypted C:, patch 5 can establish a last-resort OS route only after checking its actual location, expected bytes and saved fallback state. It reports warning and retains the Registered journal, candidate and task for dedicated remediation. Preflight deferral does not trigger this switch.
Backup sidecar write failure. The WIM copy and SHA256 verification succeeded, but backup.json could not be written. The log records Backup sidecar write failed: ... - the WIM is present and verified; sidecar is metadata only. The backup WIM remains usable for Restore. No deployment state is written; inspect the destination’s metadata-write failure. See backup troubleshooting.
Source-ownership driver-enumeration failure (v49). Before the source-ownership classification can run, the pipeline enumerates the mounted image’s third-party driver set with Get-WindowsDriver. The enumeration is retried up to three times (5-second sleeps between attempts) to recover from a transient DISM WIM provider state — for example, “Class not registered” (COM error 0x80040154) when the provider’s session state is briefly unavailable. If all three attempts fail, the classification cannot be performed: the source-ownership decision requires the third-party driver count to distinguish Foreign-No-Drivers from Foreign-With-Drivers, and the never-downgrade check requires the pre-strip inventory to compare against. The run dismounts with -Discard, removes base.wim and any stale winre_optimized.wim, resets the checkpoint to Step=2, and exits EXIT_WARNING. No partition was touched, WinRE was not disabled, no state file was written. A persistent enumeration failure is a diagnostic problem with the DISM WIM provider or the mounted image; see troubleshooting.md.
Foreign-With-Drivers source preserved (v49; layout repair added in patch 5). The servicing candidate is discarded and the original bytes remain unchanged. Patch 5 still checks dedicated capacity and can relocate the preserved source; preservation alone no longer implies an immediate exit with no partition work. A warning describes the observed preservation/deferral or another non-fatal condition; completed verification can produce PRESERVED-DEDICATED. The accepted hash remains separate from CurrentImageHash.
Never-downgrade detection (v49). The candidate would replace an existing storage driver with an older version, so the whole servicing candidate is discarded. The original source is preserved; patch 5 still evaluates its recovery layout and can use unchanged-image relocation. Inspect the final route and any pending-operation outcome rather than interpreting preservation as proof that WinRE is functional.
Strip-failure abort (v47). Step 3’s strip stage (Remove-AllThirdPartyDrivers) rejected the candidate. Every failure mode of the strip — initial Get-WindowsDriver enumeration failure, re-enumeration failure at any iteration, a missing Driver field on an enumeration entry, Remove-WindowsDriver failure for any entry, iteration-budget exhaustion without reaching zero, or a final enumeration that returns a non-zero count — exits EXIT_WARNING immediately, before injection is attempted, before export, before any partition work, and before any reagentc call. The log line is Strip stage failed - candidate rejected. Dismounting with -Discard and deferring before injection, export, partition work, or WinRE disable. The abort branch dismounts the mounted image with -Discard, removes the mount directory, sets the checkpoint back to Step=2, removes base.wim and any stale winre_optimized.wim, and exits. The machine is left unchanged: no partition touched, no WIM deployed, WinRE not disabled, no state file written. Enumeration failure is never interpreted as zero drivers — a candidate that cannot be proven clean is discarded rather than deployed. This is the v47 addition. Under v49 the strip stage is only reached when the source-ownership classification is not Foreign-With-Drivers — a foreign-with-drivers source skips the strip, so this abort is not reachable on such a source.
Base-WIM copy-integrity check rejected the candidate (v47 patch 2). After Copy-Item in Step 2, the destination base.wim is hashed and compared to the source-selection SourceHash. A mismatch or an unreadable destination rejects the candidate: base.wim is removed, the checkpoint is set back to Step=2, and the run exits EXIT_WARNING. The check exists because the Step 3 and Step 4 checkpoints bind to the source hash; without it, a checkpoint could record a hash that did not describe the bytes that actually entered servicing. The log line is Base WIM copy hash mismatch: source=..., copied=... - rejecting candidate or Base WIM copy is unreadable after Copy-Item - rejecting candidate. The machine is unchanged: no WIM deployed, no partition touched, WinRE not disabled. Investigate whether the source changed during acquisition — the same class of race the pre-/disable race detector catches later.
Pre-deployment storage-applicability gate refused the candidate (v49). The gate runs inside Step 3, after injection is confirmed complete and after the never-downgrade check, before ResetBase and before the dismount. Every present SCSIAdapter-class device on the machine must have at least one INF in the mounted candidate image whose HardwareID or CompatibleID prefix-matches one of the device’s IDs. A candidate that leaves any controller unmatched is refused: the mounted image is dismounted with -Discard, base.wim and winre_optimized.wim are removed, the checkpoint is set back to Step=2, and the run exits EXIT_WARNING before ResetBase and before the dismount would commit the candidate. No WIM is deployed, no partition is touched, WinRE is not disabled. The gate was added after the ASUS-incident field case: a machine whose controller (PCI\VEN_8086&DEV_7D0B) was not in the manifest’s VMD patterns would have received a candidate with no driver for it — a recovery environment that boots but cannot see the OS disk. This gate has never fired in the field. A field log of the refusal is high-signal; the harness Option 1 “Storage controllers” block (v28) surfaces the machine’s controller IDs alongside the manifest’s VMD patterns, which is what a bug report should include.
Architecture-gate refusal (v48 patch 1). The startup architecture check refuses to run on any architecture other than x64. The token is derived from PROCESSOR_ARCHITECTURE with PROCESSOR_ARCHITEW6432 taking precedence when present; Win32_OperatingSystem.OSArchitecture is consulted only as a 32-bit-OS fallback. ARM64, x86, and any architecture whose token cannot be resolved produce Unsupported OS architecture '<arch>': this manager supports x64 only. No WinRE, partition, image, checkpoint, or recovery-state changes have been made. and exit EXIT_WARNING before the manifest fetch, the OEM pack resolution, the DesiredStateId computation, or any state-modifying action. The machine is unchanged: no partition touched, no WIM deployed, WinRE not disabled, no state file written. This is a stable deferral — any machine whose architecture is not x64 will continue to exit 2 on every run until the manager adds support or the machine is replaced. ARM64 support is not claimed; a future fleet requirement would be a separate, tested change.
Native-boot VHDX fail-closed gate (v49). The startup topology check refuses to run destructive operations when the OS disk’s bus type is File Backed Virtual and at least one other disk is on a physical bus — the native-boot VHD/VHDX topology, where the running OS disk is a VHD/VHDX stored on a host physical disk and the host disk appears to the running OS as a non-OS disk subject to the stray-recovery cleanup. A hypervisor guest whose entire storage stack is virtual (every other disk on Virtual or File Backed Virtual) is not refused. The existing gate protects this host-visible topology; ordinary virtual-machine disks are not refused merely because the host stores them in a virtual-disk file. The run logs the topology-named refusal and exits EXIT_WARNING before any partition or WinRE change; the state file is unchanged. This is a stable deferral: a VHDX-boot machine will continue to exit 2 on every run until the topology is supported or the machine is converted. The gate has no -DryRun carve-out — the topology is a property of the machine, not of the run mode.
Intervening-anchor surplus rejection (v48 patch 1). The intervening-anchor plan (the C: | D: | Recovery layout) rejects with intervening anchor is N MiB smaller than the plan requires to seat the recovery partition at the disk tail; this v48 scope does not extend the anchor (BitLocker). Manual intervention: extend the anchor to close the gap, or reduce the desired recovery partition size, then re-run. when the recovery partition being reclaimed is larger than the new bucket size, i.e. when the anchor’s current end is farther from the disk tail than the plan needs. The v48 scope does not extend the anchor; a BitLocker-encrypted anchor is not safely growable via Resize-Partition alone, and the invariants forbid additional manage-bde work on the anchor. The run defers with the old recovery route preserved, no partition touched. The operator path: extend the anchor to close the gap, or reduce the desired recovery partition size, then delete C:\Recovery\OEM\winre_state.json and C:\Recovery\OEM\winre_partition_deferred.json to force a retry.
Multi-intervening rejection (v48 patch 1). A C: | D: | E: | Recovery layout — two or more non-recovery partitions between C: and the type-coded recovery cluster — still rejects, as it did under v47. The v48 message names the intervening partitions with Format-PartitionRef enrichment: recovery-typed partitions exist beyond the intervening anchor's recovery cluster; this layout is not supported (intervening: disk N part M, ...). The old recovery partition is intact; no partition was touched. This is the same stable deferral as v47; automating multi-intervening handling was floated as a v49 candidate, but v49 shipped without it, so it remains a candidate for a future release.
Offline LocalInputsId mismatch (v48 patch 1). When the driver manifest fetch fails and the state file indicates a full update is needed, the offline fallback engages. If the state file was written by v48 or later and the current locally-computable inputs hash differs from the stored LocalInputsId, the run defers with Offline fallback: stored LocalInputsId <hash> does not match the current locally-computable inputs <hash>. A hardware or OS input changed while the machine was offline; the stored DesiredStateId no longer describes this machine. rather than trusting a stored DesiredStateId that describes a machine whose hardware or OS has since changed. The machine is unchanged; the next run with network recomputes the DSI and either converges or defers normally.
Restore /enable failure after WIM replacement (v49). The -Action Restore operation wrote a previously captured WIM back to the currently registered route, reagentc /setreimage succeeded, but reagentc /enable returned failed or bitlocker — or, on the bitlocker variant, the target partition could not be prepared for reagentc. The state file, checkpoint, and deferral marker have already been deleted at this point (the WIM changed, so the deployment identity is invalidated), and the resume task’s persist flag is set. The script logs Restore: WIM replaced but reagentc /enable returned <failed|bitlocker> and exits EXIT_WARNING. The next boot (or the T+1h one-shot) re-invokes the script with its default Repair action, which re-attempts the enable against the current WIM. This path has not been exercised in the field. (The sibling restore failure — /setreimage failing after the WIM was replaced — exits EXIT_FATAL, not EXIT_WARNING; see the EXIT_FATAL section.)
Step 3 → Step 4 pipeline gate (v44 patch 1). OEM or VMD injection failed ($Script:ImageInjectionComplete = $false). The script exits with EXIT_WARNING immediately after Step 3, before Step 4 (dism /Export-Image), before Step 5 (partition work), before Step 6 (deployment), and before any reagentc call. The pipeline sets the checkpoint back to 2 so the next run re-acquires the base WIM from source and re-runs injection against a clean WIM. The state-write gate alone would not have prevented the deployment of a WIM with no OEM or VMD drivers; the pipeline gate closes that gap. On a VMD-based system the resulting WinRE cannot see the OS disk at all, so this exit is a protective failure, not a degraded-success. The winre_optimized.wim from the run is removed by the gate before exiting, and as of v44 patch 3 the abort branch also removes base.wim from WorkDir so the next run’s Step 2 can rename cleanly. Under v47 this gate is reached only if the strip stage succeeded — a strip failure exits via the strip-failure abort above, and the pipeline gate is not reached. Under v49 the gate is also reached only if the never-downgrade check passed and the storage-applicability gate passed — a never-downgrade detection exits via that case above, and a candidate refused by the applicability gate exits via that gate’s case above; the injection-failure gate is not reached on either of those paths. The three paths have the same exit code, the same checkpoint rollback, and the same disk-state outcome; the difference is that the injection-failure gate has already captured the pre-injection third-party driver count and has already attempted Add-WindowsDriver.
Audit Mode / OOBE / sysprep deferral (v43 patch 5, further revision). The startup guard reads HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State → ImageState before any other action. When the value is present and is not IMAGE_STATE_COMPLETE, Windows is in a transitional state (Audit Mode, OOBE, sysprep generalize, or sysprep specialize) where reagentc /enable is blocked with ERROR_CANCELLED (0x4c7, 1223) regardless of WIM correctness or the state of the recovery partition. The run logs a clear message naming the ImageState value and defers before the hardware check, the manifest fetch, the OEM pack resolution, the DesiredStateId computation, or any state-modifying action. The machine is left unchanged: no partition touched, no WIM deployed, WinRE not disabled, no state file written, checkpoint file preserved. Under -DryRun the gate performs the same read-only classification and logs Would defer … without exiting. This is the highest-priority deferral after the program lock and the elevation guard — it runs before every other gate.
VMD-query-indeterminate deferral (v44 patch 6). The VMD hardware presence check is fail-closed. The query wraps Get-PnpDevice -PresentOnly in -ErrorVariable and treats any enumeration error as an indeterminate result, not as “VMD hardware absent”. On an indeterminate result the correct driver set cannot be determined: proceeding might select a driver set that omits the VMD package on a machine that has VMD hardware, and the resulting WinRE would not see the OS disk. The run logs the enumeration error, sets $Script:nonFatalWarning = $true, removes the checkpoint file, and exits EXIT_WARNING before committing any state. No WIM is deployed, no partition is touched, no reagentc call is made. The next run retries the enumeration; a transient PnP service issue is the most likely cause. See troubleshooting.md.
OS-fallback BitLocker deferral (v43 patch 5, further revision 5). On the OS-fallback route — reached when dedicated-partition creation fails and the script falls back to C:\Recovery\WindowsRE — the target volume is the OS volume. reagentc refuses to enable WinRE on an encrypted OS volume, always. The OS-fallback gate checks C: via Test-VolumeEncrypted -MountPoint "C:" before deploying the WIM and defers with EXIT_WARNING unless the classifier returns exactly $false (confirmed fully decrypted). The script never modifies C:’s BitLocker state — decrypting the OS volume is hours of I/O, changes the recovery key relationship, and the OS volume is the user’s data. The machine is left unchanged: no WIM deployed, no reagentc call made, no state file written. The checkpoint file is removed; the next run restarts WIM preparation from Step 1. The log message names the classifier result and the resolution: complete decryption of C: (manage-bde -off C:), or wait for an in-progress decryption to finish. The log message explicitly states that completing encryption, adding a recovery-password protector, or enabling protection do not satisfy the FullyDecrypted requirement — those actions make C: more protected, not less. Under -DryRun the gate logs the deferral and continues. Note that this gate is only reached on the OS-fallback route; the enable-only and dedicated-partition routes never depend on C:’s BitLocker state, because their target volume is the recovery partition.
Registered-source fingerprint abort at the Ensure-AdequateRecoveryPartition site (v47). The race detector captured the registered WinRE image’s location, version, and WIM SHA256 at the start of the rebuild, then re-read them immediately before the /disable that Ensure-AdequateRecoveryPartition would perform. If any of the three changed — typically because Windows Update serviced or replaced the registered image during candidate preparation — the abort fires before /disable. The function restores the resize target (C:, or the intervening anchor when applicable) to its captured size via Restore-OSPartitionSize, invalidates the checkpoint back to Step=2, removes base.wim and any stale winre_optimized.wim, and returns Deferred with Reason = "registered source changed before disable". The main flow exits EXIT_WARNING. Because the abort fires before /disable, WinRE is still Enabled and registered to its original location, no partition has been deleted, and the recovery route is intact. The log lines are Registered WinRE source changed during candidate preparation - aborting before /disable. Restoring <resize-target label> to its captured size; no partitions have been deleted. followed by Dedicated replacement deferred before partition deletion (registered source changed before disable). The existing WinRE route was preserved; not attempting OS-fallback. This is a race detector, not a lock — the microseconds between the final re-read and /disable returning cannot be closed without moving the re-read inside the disable→enable window and violating Rule 3. The detector narrows the exposure window from minutes to that residual. See architecture.md — “The v47 rebuild pipeline” — “The pre-/disable race detector”.
Registered-source fingerprint abort at the Step 5 deployment site (v47). The same race detector, invoked at the other /disable site. When Ensure-AdequateRecoveryPartition did not run (the existing recovery partition was reusable), the first /disable of the execution is the one in the Step 5 deployment path. The recheck runs immediately before it. If any of location, version, or WIM hash has changed since capture, the run invalidates the checkpoint back to Step=2, removes base.wim and any stale winre_optimized.wim, sets $Script:nonFatalWarning = $true, and exits EXIT_WARNING. The log line is Registered WinRE source changed during candidate preparation - aborting before /disable. The old WinRE route remains intact; no partition changes have been made at this site. Because this abort fires before /disable, WinRE is still Enabled, no partition was touched, and the recovery route is intact. Only one of the two race-detector sites fires per execution — whichever /disable the run reaches first — so there is exactly one recheck per rebuild.
Dedicated recovery partition creation deferred before partition deletion (v45 patch 1; v46 patch 2 added two reasons; v47 added one; v48 patch 1 moved the active-route resolver ahead of the pre-shrink). Ensure-AdequateRecoveryPartition runs a read-only geometry plan and, when the plan calls for a resize, performs the resize in the reversible window — before reagentc /disable and before any partition deletion. Any of the following conditions causes the function to return Deferred and the main flow to exit EXIT_WARNING with the old recovery route preserved:
Get-PartitionSupportedSize or the disk-layout enumeration failed. RetrySuppressible = $false; the deferral marker is not written.RetrySuppressible = $false; the deferral marker is not written.-ProtectedSourcePath but Get-Volume -FilePath could not resolve the source WIM to a storage partition. The destructive sequence is refused before any mutation so the deployment source cannot be deleted by the plan. RetrySuppressible = $false; the deferral marker is not written.-ProtectedSourcePath and the resolved source WIM’s partition is in the plan’s deletion set. The destructive sequence is refused before any mutation so the source WIM is not destroyed mid-deployment. RetrySuppressible = $false; the deferral marker is not written.Get-Volume -Partition $resizeTarget returned nothing for the OS partition or for the intervening anchor. Fail-closed: the script refuses to shrink without verifying the 3 GiB reserve. RetrySuppressible = $false; the deferral marker is not written. The read failure may be transient.RetrySuppressible = $true; the deferral marker is written.RetrySuppressible = $true; the deferral marker is written.RetrySuppressible = $true; the deferral marker is written.RetrySuppressible = $true; the deferral marker is written.reagentc /disable returned non-zero, or the subsequent status check did not report Disabled. RetrySuppressible = $false; the deferral marker is not written. The run attempted Restore-PreviousWinRERoute first; the Deferred result is returned only when the previous route was confirmed restored./info reported a status that is neither Enabled nor Disabled, typically on a non-English OS whose output the parser does not classify. The destructive sequence is refused before any mutation. RetrySuppressible = $false; the deferral marker is not written.Enabled but Resolve-WinRELocationToPartition returned nothing for the registered location, or reagentc reports no registered location at all. Delete-last ordering and route restoration both depend on identifying which partition is active; without it, no partition is protected and a mid-loop failure could leave the machine with no working recovery route. As of v48 patch 1 the guard fires ahead of the pre-shrink and ahead of reagentc /disable, so the machine is left with WinRE still Enabled and the old recovery partition intact. RetrySuppressible = $false; the deferral marker is not written./disable race detector aborted. See the dedicated case above. RetrySuppressible = $false; the deferral marker is not written. The abort restores the resize target to its captured size, invalidates the checkpoint back to Step=2, and removes base.wim and any stale winre_optimized.wim. The resize target is verified at its original size before the Deferred result is returned — if Restore-OSPartitionSize failed, the state file is deleted so the next run retries from clean.Restore-PreviousWinRERoute confirmed the previous route is still functional (the active partition is deleted last, so it remained available). RetrySuppressible = $false; the deferral marker is not written. As of v46 patch 2, the two restores are reported separately. When Restore-OSPartitionSize verified the resize target at its original size, the reason is recorded as recovery partition deletion failed; previous route restored. When the resize target could not be verified at its original size, the reason is recorded as recovery partition deletion failed; previous route restored but <resize-target label> geometry restore unverified (the label is OS partition (C:) on the non-intervening path and anchor partition (disk X part Y) on the intervening-anchor path; v48 patch 1) and $Script:GeometryRestoreFailed is set — the state file is invalidated so the next run retries from clean.These refusals do not authorize OS-fallback. Before deletion, the prior route is retained when it can be verified. A deletion failure can follow earlier deletions, and geometry restoration can fail; inspect the actual route and geometry results. An initially Disabled or indeterminate route is not made Enabled by a deferral.
The v46 patch 2 resolver deferral (active WinRE location could not be resolved). As of v48 patch 1 this guard fires ahead of the pre-shrink and ahead of reagentc /disable, so the machine is left with WinRE still Enabled and the old recovery partition intact; the pre-v48-patch-1 placement (after /disable) is no longer the current behavior. See troubleshooting.md for the reason-specific resolutions.
The v47 patch 1 race-detector abort (registered source changed before disable) fires before /disable but after the pre-shrink, so the resize target is restored to its captured size and the old WinRE route remains intact and Enabled. Because this abort returns RetrySuppressible = $false, no sidecar is written for this reason. The general deferral-marker mechanism (write, honor, clear) is described in the Dedicated recovery partition creation deferred before partition deletion bullet above and does not apply here; the next run re-evaluates source selection from the top. See troubleshooting.md for the reason-specific resolutions.
Enable-only target-preparation failure (v43 patch 5, further revision 5). The enable-only path prepares the target recovery partition via Set-RecoveryPartitionReadyForWinRE before calling reagentc /setreimage. If the helper reports that the target could not be made unencrypted within its 300-second timeout, the enable-only path records the failure, increments the state file’s EnableFailureAttempts counter, writes LastEnableResult = "failed", removes the checkpoint file, and exits EXIT_WARNING. The deployment is already current; the next run will retry enable-only. After three consecutive failures the loop-breaker fires and the next exit is EXIT_FATAL (see below).
Enable-failure counter (v43 patch 5, further revision). The enable-only path called reagentc /enable on a deployment that was already current. The call returned a terminal failure — either a generic "failed" result or a "bitlocker" result (reagentc refused because the target volume is BitLocker-protected, even after the helper prepared it). The enable-only path increments the state file’s EnableFailureAttempts counter, writes LastEnableResult to the corresponding value, removes the checkpoint file, and exits with EXIT_WARNING. It does not fall through to full update: the deployment is current, and rebuilding it would not change the outcome of the enable step. The next run will retry the enable-only path (not the full-update path). After three consecutive terminal failures the loop-breaker fires and the next exit is EXIT_FATAL (see below). Both "failed" and "bitlocker" count toward the same three-failure threshold; they are not distinguished by the counter.
Concurrent-instance deferral (v44 patch 4). A second WinRE.ps1 process was launched while another instance was already running. The program lock at C:\ProgramData\OEM\Logs\WinREManager.lock is held exclusively by the first instance (FileShare.None via [System.IO.File]::Open), and the second instance cannot acquire it. The second instance logs Another WinRE Manager instance is already running (program lock file is exclusively held). Exiting without making any changes. This is not a deployment failure - the other instance is doing the work and will complete on its own. … and exits EXIT_WARNING immediately, before the Audit Mode guard, before the hardware check, and before any state-modifying action. The state file is not read, not written, and not modified; the checkpoint file is untouched. The lock is not acquired under -DryRun, so a concurrent dry run is not affected. As of v44 patch 4 this failure shape replaces the pre-patch-4 rename error at C:\Temp\WinREWork\winre.wim, which was reported as EXIT_FATAL (code 3). The rename error is still reachable in the narrow case where the lock acquisition fails for a reason other than contention — a permission error, a missing Logs directory, or a transient filesystem issue — in which case the script logs Could not set up program lock at <path> : <error> - proceeding without single-instance protection; concurrent runs may collide and continues unprotected. See the EXIT_FATAL section for that narrow case. The v49 temporary WinRE Manager - Resume task does not participate in the program lock — it invokes the production script with its default Repair action, which acquires the lock normally; a resume run that coincides with a scheduled run is therefore serialized by the same lock.
Offline-fallback deferral (v44 patch 5). The driver manifest fetch failed after its retry budget (typically a DNS failure, a proxy block, or a total network outage), and the state file was present and parseable but the fast path did not fire — meaning the state file indicates a full update is needed (stale DSI, force-upgrade, driver-version drift, a missing state-file metadata anchor, an unreadable registered-WinRE metadata, or a locally-detected input change). A full update requires the live manifest to resolve the driver set, which is unavailable. The run logs Offline fallback: the machine requires a full update (state file is stale or unhealthy), but the driver manifest is unavailable. Cannot proceed without a live manifest. Will retry on the next scheduled run when the network is available. and exits EXIT_WARNING without touching the machine. No WIM is deployed, no partition is touched, WinRE is not disabled, no state file is written or modified. The checkpoint file is removed; the next online run restarts WIM preparation from Step 1. If the state file’s fast-path checks do pass, the offline run does not exit with this message — it takes the fast path and exits EXIT_WARNING because $Script:offlineFallback = $true (see the “Fast path under offline fallback” case below). If there is no state file at all, the run throws and exits EXIT_FATAL (code 3) — a first deployment on a machine with no state file requires the live manifest. The offline fallback and its residual risk are documented in state-and-idempotency.md and architecture.md. The v49 pipeline refinements (source-ownership classification, never-downgrade check, storage-applicability gate) run inside the full-update path, which the offline fallback does not reach; they do not add new offline-path conditions.
Fast path under offline fallback (v44 patch 5; metadata-based as of v47). A special case of the offline-fallback deferral. When the manifest fetch fails and the state file is present and its local safety checks pass (WinRE Enabled, exactly one type-coded recovery partition on the OS disk, and — as of v47 — a DeployedWinREMetadata anchor in the state file whose Version|SPBuild matches the currently-registered image’s servicing metadata), the script takes the fast path successfully but still exits EXIT_WARNING because $Script:offlineFallback = $true is set. The v46-and-earlier deployed-WIM-hash-vs-CurrentImageHash comparison no longer gates the offline fast path; it was retired in v47 in favour of the metadata comparison. A state file written by v46 or earlier has no anchor and forces a rebuild on the first v47 run regardless of network state. From the second v47 run onward the offline check is metadata-based. The log shows the offline-fallback engage line (Driver manifest unavailable - taking the offline fallback path using the state file's stored DesiredStateId ...), followed by Offline fallback: skipping OEM pack resolution (network unavailable), Offline fallback: skipping VMD detection (manifest unavailable), Offline fallback: skipping required-driver resolution, Offline fallback: using state file's stored DesiredStateId <id>, WinRE status: Enabled, Location: ..., Version: ..., State file accepted (DesiredStateId match), Operating mode: DEDICATED (WinRE on dedicated recovery partition), Released program lock. Exit code 2. Total runtime under 90 seconds. The machine is unchanged. The next scheduled run with network performs a full manifest fetch, detects any hardware drift that occurred while offline, and either takes the fast path (if no drift) or forces a rebuild (if drift).
$Script:nonFatalWarning = $true. Set by a range of non-fatal conditions the run encountered: Restore-OSPartitionSize failure on any post-shrink geometry-restore path, Remove-OrphanPartition orphan survival, Remove-StrayRecoveryPartitions cleanup failure, Set-RecoveryPartitionAttributes failure at the end of Step 6, the full-update post-enable "failed" and "bitlocker" outcomes, OEM map resolution failure for a supported vendor, Set-RecoveryPartitionReadyForWinRE failure on any deferring path, the OS-fallback BitLocker gate, the v44 patch 4 lock-acquisition failure, the v44 patch 6 VMD-query-indeterminate deferral, the v45 patch 1 post-delete extension safe fallback, the v47 pre-injection discrepancy check (when the filtered pre-injection third-party count is non-zero despite a successful strip), the v49 foreign-source preservation (when a Foreign-With-Drivers source is retained instead of normalized), and the v49 never-downgrade detection (when the whole candidate is discarded on a detected downgrade). Fallback copy denial (ACL) sets the warning flag as of v48 patch 1; the earlier behavior (logged without affecting the exit code) was corrected because a machine with a degraded LKG copy would otherwise exit EXIT_SUCCESS while its next-run fallback safety was compromised — the denial remains non-fatal to the deployment itself but the run now exits EXIT_WARNING, consistent with the exit-code discipline.
Post-delete extension safe fallback (v45 patch 1; ceiling-fill in v47 patch 2). When the plan calls for C: to grow into the space the old recovery partitions occupied, Invoke-OSPartitionExtend runs after the deletions. If all three extension attempts fail, the safe fallback creates the recovery partition at the current (un-extended) C: end, sized to min(AvailableSize, 2 GiB) — the full available extent, capped at the managed-recovery ceiling — sets $Script:nonFatalWarning = $true, and continues with WinRE deployable. Sizing to the ceiling fills the extent in the common case (the surplus after a failed extension is typically a few hundred MiB, well under the ceiling), eliminating the trailing unallocated extent. Only when the surplus exceeds 2 GiB does a trailing extent remain, and it is logged explicitly. The end state is DEDICATED, but the exit code is EXIT_WARNING because of the warning flag. Exact geometry is a goal, not a reason to leave WinRE disabled. If the space available after the current C: end is smaller than the plan’s bucket size, the script restores C: to its original size and returns $null; the main flow falls through to the OS-fallback decision, which either succeeds (state file written with UsedOSFallback = true, exit EXIT_WARNING) or defers (OS-fallback BitLocker gate on encrypted C:, exit EXIT_WARNING).
$Script:UsedOSFallback = $true. Distinct from nonFatalWarning; can be true without any warning-level event, and is the deliberate outcome of the shrink-fails path.
Warning can arise before any deployment or after completed work with a non-fatal condition. Backup and Restore also return it from their own validation/failure paths. State may remain unchanged, be updated, or be invalidated after replacement or geometry failure; preservation alone does not determine that outcome. Read the route verification, state-write and pending-operation messages together.
Important for orchestration: the table below summarizes warning and refusal cases that require different actions. A lost active route or failed required persistence check can make a patch 5 transition fatal. The bulleted list above this paragraph describes the underlying conditions in more detail; some bullets map to a single table row and a few do not appear as their own row. The state file’s LastUpdated timestamp, the presence of the UsedOSFallback flag, the presence of the deferral marker at C:\Recovery\OEM\winre_partition_deferred.json, the presence of a WinRE Manager - Resume scheduled task, and the specific log content distinguish them.
| Case | State file LastUpdated |
Log signature | Action |
|---|---|---|---|
| OS-fallback | Saved fallback state; pending record retained | Last-resort fallback and retained-operation messages | Dedicated creation actually failed, geometry was verified and C: was fully decrypted. Inspect actual registration/hash checks. The warning retains candidate, journal and task for dedicated remediation; it is not a healthy fast-path state. |
| Source-ownership driver-enumeration failure (v49) | Unchanged, or state file absent | Source-ownership decision: driver enumeration failed after 3 attempts: … - candidate rejected |
The pre-classification enumeration of the mounted image’s third-party driver set failed all three retries. The classification cannot be performed without the driver count, so the candidate was discarded. No WIM was deployed, no partition touched, WinRE not disabled. The checkpoint was set back to 2. Investigate the DISM WIM provider state; the failure may be transient. |
Foreign-With-Drivers source preserved |
Depends on layout/commit outcome | Foreign source preserved byte-identically; assessing dedicated layout without strip, injection or export. |
Original bytes are preserved; patch 5 still assesses and can repair dedicated placement. Acceptance stays separate from CurrentImageHash; matching DSI alone does not skip layout remediation. |
| Never-downgrade detection | Depends on layout/commit outcome | Never-downgrade invariant: discarding the candidate edits and preserving the original source bytes. and per-driver detail |
Servicing edits are discarded; unchanged-source placement is assessed independently. Inspect the final route and pending record. |
| Strip-failure abort (v47) | Unchanged, or state file absent | Strip stage failed - candidate rejected. Dismounting with -Discard and deferring before injection, export, partition work, or WinRE disable. |
The strip stage could not normalize the mounted image to zero third-party drivers. The WIM was not deployed, the partition was not touched, and WinRE was not disabled. The checkpoint was set back to 2, and base.wim and any stale winre_optimized.wim were removed. The next run will retry from step 2 and re-acquire the source. Investigate the specific strip failure reason (enumeration, removal, missing INF field, or budget exhaustion) in the log lines immediately preceding the abort. |
| Storage-applicability gate refusal (v49) | Unchanged, or state file absent | Line naming the candidate image path, the machine’s present SCSIAdapter-class devices, and the count of controllers with no matching INF (e.g. 2 of 4 storage controller(s) have no matching INF in the candidate image). |
The candidate WIM was fully prepared — mounted, source-ownership-classified, strip-applied or preserved, injected, never-downgrade-checked — and then refused by the applicability gate before ResetBase and before the dismount. The WIM was not written to the active route; no partition was touched, WinRE was not disabled. This gate has never fired in the field — a field log is high-signal. Operator action: run Test-WinRE.ps1 Option 1 (harness v28) and compare the “Storage controllers” block against the manifest’s VMD patterns; update the manifest’s requiredDevices patterns to include the machine’s controller, or update the OEM pack resolution to a version whose INFs match, then delete the state file and re-run. |
| Base-WIM copy-integrity check (v47 patch 2) | Unchanged, or state file absent | Base WIM copy hash mismatch: source=..., copied=... - rejecting candidate or Base WIM copy is unreadable after Copy-Item - rejecting candidate |
The candidate base.wim did not match the selected source’s SHA256, or the copied file could not be re-read. The candidate is removed, the checkpoint is reset to Step 2, and the run exits EXIT_WARNING. Investigate whether the source changed during acquisition. |
| Step 3 → Step 4 pipeline gate | Unchanged, or state file absent | Image injection did not complete. Stopping before Step 4 and before any deployment. |
The OEM or VMD injection failed after a successful strip, never-downgrade check, and applicability gate. The WIM was not deployed, the partition was not touched, and WinRE was not disabled. The checkpoint was set back to 2. The next run will retry from step 2. Investigate the injection failure reason (OEM pack download, extraction, INF validation, or VMD driver download). |
| Audit Mode deferral | Unchanged, or state file absent | Deferring WinRE Manager: Windows is not in a normal-running state (Setup\State\ImageState=…) |
The machine has not finished OOBE, or is in Audit Mode or a sysprep phase. No partition work was attempted. Complete OOBE, sign in to a normal desktop session, and re-run. Do not retry immediately. |
| VMD query indeterminate (v44 patch 6) | Unchanged, or state file absent | VMD hardware detection reported N error(s) during PnP enumeration: … followed by VMD hardware detection was indeterminate; deferring because the driver set cannot be safely determined. |
A PnP enumeration error prevented the VMD hardware presence check from completing. The correct driver set cannot be determined, so the run defers rather than guessing. No WIM was deployed, no partition was touched, no reagentc call was made. Resolve the PnP service issue (Windows device management, an antivirus/EDR product blocking device enumeration, a device in an error state) and re-run. |
| OS-fallback BitLocker refusal | Depends on the preceding transition; unresolved operation retained | Fallback refusal because C: is not confirmed fully decrypted | Patch 5 first attempts safe dedicated remediation. Encrypted C: cannot authorize last-resort fallback. If the active recovery partition was lost, failure is fatal rather than a healthy warning. Do not decrypt C: merely to bypass this policy. |
| Partition preparation deferred | Usually unchanged; geometry failures can invalidate state | The reason returned by partition preparation | Read the specific capacity, query, source, resize or restoration result. A pre-deletion refusal retains the old partition; a deletion failure may follow partial work. Capacity is reassessed and eligible execution failures receive a one-hour backoff. |
| Registered-source fingerprint abort at Step 5 (v47) | Unchanged, or state file absent | Registered WinRE source changed during candidate preparation - aborting before /disable. The old WinRE route remains intact; no partition changes have been made at this site. |
The v47 race detector caught a Windows Update servicing event during candidate preparation, at the Step 5 /disable site. WinRE is still Enabled, no partition was touched, no WIM was deployed. The checkpoint was set back to 2, and base.wim and any stale winre_optimized.wim were removed. Simply re-run — the next run will re-select the source and prepare a fresh candidate based on the newly-registered image. This is not a failure; it is the design’s intended response to a source that changed mid-preparation. |
| Enable-only failure (counter < 3) | Newer than the run start (state file written this run, with LastEnableResult set to "failed" or "bitlocker" and the counter incremented) |
One of: Enable-only /enable failed (attempt N of 3).; Enable-only /enable refused with the BitLocker error after the target partition was confirmed unencrypted (attempt N of 3).; Enable-only path: target recovery partition could not be made unencrypted - deferring without further changes (target-preparation failure). |
The deployment is current; only the enable step failed. Do not rebuild. Investigate the enable failure itself (ReAgent.xml corruption, missing registration, a Windows component problem, an antivirus product holding the recovery partition open). The next run will retry enable-only. After three consecutive failures the loop-breaker fires and the next run exits with code 3. |
| Concurrent-instance deferral (v44 patch 4) | Unchanged, or state file absent | Another WinRE Manager instance is already running (program lock file is exclusively held). |
Not a failure. The other instance is doing the work and will complete on its own. Do not investigate the log for a deployment problem, do not retry, do not intervene. If your orchestration treats exit 2 as a soft failure and re-queues the remediation, be aware that the re-queue will also exit 2 until the first instance completes. Either wait, or disable the scheduled task before running a manual remediation. See deployment.md. A resume task and a scheduled task are serialized by the same lock; a resume run that coincides with a scheduled run produces this deferral on whichever side loses the race. |
| Offline-fallback deferral (v44 patch 5) | Unchanged, or state file absent | Offline fallback: the machine requires a full update (state file is stale or unhealthy), but the driver manifest is unavailable. Cannot proceed without a live manifest. Will retry on the next scheduled run when the network is available. |
The network was unavailable and the state file indicates a full update is needed. A full update requires the live manifest to resolve the driver set. No WIM was deployed, no partition was touched, WinRE was not disabled, no state file was written or modified. No operator action is required — the next scheduled run with network will complete the work. If the log instead shows Offline fallback: using state file's stored DesiredStateId …, the fast path fired successfully and the outcome is a degraded-success, not a deferral — see the “Fast path under offline fallback” row below. |
| Fast path under offline fallback (v44 patch 5; metadata-based as of v47) | Unchanged, or state file absent | Offline fallback: using state file's stored DesiredStateId <id> |
The network was unavailable but the state file’s local safety checks all passed, so the fast path fired successfully. This is a degraded-success, not a deferral. The machine is healthy and unchanged. No operator action is required; the next run with network will re-evaluate the DSI and either converge or force a rebuild if any input has drifted while offline. |
| Architecture-gate refusal (v48 patch 1) | Unchanged, or state file absent | Unsupported OS architecture '<arch>': this manager supports x64 only. |
The startup architecture check refused. Expected on ARM64, x86, or machines whose architecture could not be resolved. No state was committed. This is a stable deferral: any machine whose architecture is not x64 will continue to exit 2 on every run until the manager adds support or the machine is replaced. Do not retry expecting a different result. |
| Intervening-anchor surplus rejection (v48 patch 1) | Unchanged, or state file absent | intervening anchor is N MiB smaller than the plan requires to seat the recovery partition at the disk tail; this v48 scope does not extend the anchor (BitLocker). |
The intervening-anchor layout (C: \| D: \| Recovery) had a surplus: the recovery partition being reclaimed is larger than the new bucket size, so the plan cannot seat the new recovery partition at the disk tail without extending the anchor. The v48 scope does not extend the anchor (BitLocker-encrypted anchors are not safely growable via Resize-Partition alone). The old recovery partition is intact; no partition was touched. Operator action: extend the anchor to close the gap, or reduce the desired recovery partition size, then delete C:\Recovery\OEM\winre_state.json and C:\Recovery\OEM\winre_partition_deferred.json to force a retry. |
| Multi-intervening rejection (v48 patch 1) | Unchanged, or state file absent | recovery-typed partitions exist beyond the intervening anchor's recovery cluster; this layout is not supported |
The layout has two or more non-recovery partitions between C: and the type-coded recovery cluster (C: \| D: \| E: \| Recovery). The v48 scope is deliberately narrow: exactly one intervening partition, no partition-moving. Same stable deferral as v47, but the v48 message names the intervening partitions via Format-PartitionRef. Automating multi-intervening handling was floated as a v49 candidate, but v49 shipped without it, so it remains a candidate for a future release. |
Offline LocalInputsId mismatch (v48 patch 1) |
Unchanged, or state file absent | Offline fallback: stored LocalInputsId <hash> does not match the current locally-computable inputs <hash>. |
The machine was offline and the state file’s stored LocalInputsId did not match the current machine’s locally-computable inputs (hardware identity, OS build, CPU vendor/generation). A hardware or OS input changed while the machine was offline; the stored DesiredStateId no longer describes this machine. The machine is unchanged. Operator action: bring the machine online so a fresh manifest can be fetched and a new DesiredStateId computed; the next scheduled run will do this automatically. |
| Native-boot VHDX fail-closed gate (v49) | Unchanged, or state file absent | Topology-named refusal that states the OS disk’s bus type is File Backed Virtual and at least one other disk is on a physical bus, and that the manager’s partition-resize and recovery-partition-creation operations are not supported under that topology. |
The startup topology check refused. No partition was touched, no WIM deployed, WinRE not disabled, no state file written. This is a stable deferral: a VHDX-boot machine will continue to exit 2 on every run until the topology is supported or the machine is converted. Do not retry expecting a different result. The gate has no -DryRun carve-out — a dry run on a VHDX-boot host also exits EXIT_WARNING. |
Restore /enable failure after WIM replacement (v49) |
Deleted (the WIM changed, so the state file was removed) | Restore: WIM replaced but reagentc /enable returned <failed\|bitlocker> |
The restore replaced the WIM on the active route and re-registered it via /setreimage, but /enable did not succeed. The temporary WinRE Manager - Resume task was preserved; the next boot (or the T+1h one-shot) will re-invoke the script with its default Repair action and complete the operation. Do not delete the resume task manually unless you intend to abandon the interrupted restore. If the task keeps reappearing after each attempt, read the log around the failing step. This path has not been exercised in the field. (The sibling restore failure — /setreimage failing after the WIM was replaced — exits EXIT_FATAL, not EXIT_WARNING; its log signature is Restore failed at reagentc /setreimage: … and it also deletes the state file.) |
Use LastUpdated together with the final route, pending record and log. It cannot distinguish all patch 5 outcomes by itself: preservation can lead to no work, deferral or byte-identical relocation, and state persistence can fail after a valid route is established.
A partition-creation failure — with its Dedicated recovery partition creation failed after all attempts. banner — is only logged when the destructive attempt actually ran and failed. A deferral or a pipeline gate is not that.
EXIT_FATAL (3)Reached when any of the following occurs:
FATAL: WinRE Manager requires an elevated (Administrator) PowerShell session. Re-run from an elevated prompt, or launch via the scheduled task's SYSTEM context. No changes have been made to WinRE, partitions, BitLocker, drive letters, the workspace, or the state file. and exits EXIT_FATAL in milliseconds. On refusal the guard creates the log directory itself so its FATAL message has somewhere to be written; the guard runs before the program lock, before hardware probes, before the manifest fetch, and before any state-modifying action. The check accepts both interactive Administrator sessions and the SYSTEM context used by the scheduled task. Under -DryRun the guard still fires. This is a fail-fast refusal for the case the 2026-10-05 field log demonstrated: an unelevated launch would otherwise spend roughly four minutes on hardware detection, manifest fetch, and the GitHub base-WIM download before failing at Mount-WindowsImage.dism /Export-Image failed. Non-zero exit from DISM or missing output file.Indeterminate WinRE status (the historical Step 5 guard). Patch 5 refuses unknown status in Main before fast-path, enable-only or servicing decisions, and at entry to pending deployment. These direct refusals return EXIT_FATAL; their summary Why: fields are WinRE status is indeterminate; refusing repair before fast-path, enable-only or servicing decisions, WinRE status is indeterminate; no target preparation or route switch attempted, or WinRE status became indeterminate during verification; no target preparation attempted. Later rechecks can log [ERROR] Pending deployment stopped: Current WinRE route cannot be verified before target preparation. or [ERROR] Pending deployment stopped: WinRE status became indeterminate before the route switch. Catch branches for a verified new route or a different registered image return fatal 3; the earlier pre-mutation source-change refusal returns warning 2. Otherwise, a caught deployment failure returns warning 2 only when no geometry-restore failure is recorded and either the previous route is verified or the journal remains Prepared; otherwise it returns fatal 3. Recovery material is retained and a registered resume task is preserved. Patch 4 used an inline Step 5 guard; that historical code shape and signature are not the patch 5 implementation. See status troubleshooting.
Prepared, can instead return warning 2. The catch also returns fatal after a verified new route when persistence/cleanup fails, or when an unexpected different image becomes registered during the attempt. Candidate, journal and any registered resume task remain available for recovery. A transactional WIM rollback can restore file bytes where its verification succeeds; it cannot recreate deleted partitions. Read the actual route, phase and failure line rather than inferring the result from an old Step 5/6 label.-Action Restore operation’s transactional helper preserves the previous WIM as a rollback copy before replacing it. The branch is reached on every WIM-deployment failure of the Restore action; the most severe sub-case is a rollback-restore failure, which may leave the machine’s WinRE WIM in an inconsistent state. The script logs the specific failure — rollback restore hash verification failed or rollback restore failed — and exits EXIT_FATAL. Before v50 patch 3, the resume task was unregistered on every WIM-deployment failure of the Restore action. As of v50 patch 3, when the previous state was Enabled and the re-enable attempt after the failure does not return ok, the branch sets $Script:ResumeTaskShouldPersist to $true, so the temporary WinRE Manager - Resume task is preserved and the next boot (or the T+1h one-shot) re-invokes the script with its default Repair action. A reboot result does not confirm WinRE is enabled; only ok does, so the persist condition is -ne 'ok', not -ne 'ok' -and -ne 'reboot'. A follow-up revision later in the same cycle (v50 patch 3 follow-up) added the state-marker handling on this branch. The branch captures the target WIM’s SHA256 before the deploy attempt and again after the failure. When the two hashes match - the target is provably unchanged (untouched, or the transactional rollback restored and hash-verified it) - the branch preserves the state file, checkpoint, and deferral marker, because those files still describe the target content. When the two hashes differ, or either hash is unavailable (Get-LiveWimHash returns $null for both absent and unreadable), the target’s content cannot be proven unchanged, and the branch invalidates the three markers so the next run does not trust stale state; in that invalidate branch, the resume-task persist flag is set unconditionally, regardless of the re-enable result, because reagentc /enable returning ok establishes only that reagentc reports Enabled, not that the target WIM’s bytes are intact. When the target bytes are proven unchanged and re-enablement is confirmed or was unnecessary, this branch does not itself request persistence; other active persist conditions still apply. This branch has not been exercised in the field and warrants a bug report with the log./setreimage failure after WIM replacement (v49). The -Action Restore operation wrote a previously captured WIM back to the currently registered route, but reagentc /setreimage returned non-zero. The state file, checkpoint, and deferral marker are deleted, and the resume task’s persist flag is set. The script logs Restore failed at reagentc /setreimage: <output> and exits EXIT_FATAL. The machine’s WIM has been replaced with the backup’s WIM, but the registration was not updated; a subsequent repair run (or the resume task’s re-invocation on the next boot / T+1h) will re-attempt registration. This path has not been exercised in the field and warrants a bug report with the log.-Action Backup fatal paths (v49; two new reasons in v50 patch 1). The backup action exits EXIT_FATAL (code 3) when it cannot complete a byte-for-byte copy. The pre-existing reasons are: the source WIM is unreadable; the destination directory could not be prepared; the copy failed; the copy’s hash did not match the source’s hash. The v50 patch 1 additions are: the destination drive letter does not resolve to a known local or mapped drive; or the destination volume has insufficient free space for the WIM plus the 100 MiB margin. The two v50 patch 1 reasons exist so that a backup against a misconfigured or too-small destination fails before the copy begins rather than partway through. No state file is written by any of these exits; the backup action does not participate in the deployment identity, and the machine’s active WinRE route is untouched.C:\Recovery\OEM\winre_state.json. A first deployment requires a live manifest. The script logs Driver manifest unavailable and no state file exists - a live manifest is required for the first deployment on this machine. and throws. The outer catch logs FATAL ERROR: … and exits 3. A machine in this state will retry on the next scheduled run when the network is available. As of v44 patch 5.RepairAttempts >= 3 in the state file. The state file records three or more failed repair attempts; the next pending-reboot run hits the FATAL guard at the start, before attempting the repair. Manual intervention is required.EnableFailureAttempts >= 3 with LastEnableResult set to "failed" or "bitlocker", and WinRE is still Disabled. The loop-breaker logs Refusing to retry reagentc /enable: it has failed on the last N consecutive runs and WinRE is still Disabled. Manual intervention is required., names the state file path, and exits EXIT_FATAL without attempting anything else. The state file is left in place so the operator can inspect it. The cause may be Audit Mode (though the Audit Mode startup guard would have deferred earlier), a broken ReAgent registration, a Windows component problem, a filesystem problem on the target partition, or an antivirus product holding the recovery partition open. Resolve the underlying cause, then delete C:\Recovery\OEM\winre_state.json to reset the counter and re-run. See the “Enable-only failure (counter < 3)” row above for the pre-loop state.winre.wim (before v50 patch 5). Patch 5 live Repair/Restore require the exclusive program lock. The following explanation describes earlier revisions. The pre-patch-4 concurrent-instance failure shape. As of patch 4 this is only reachable when the lock acquisition failed for a reason other than contention — a permission error, a missing Logs directory, or a transient filesystem issue — and the run proceeded unprotected. In that case a second instance can still collide at Step 2 and exit with Cannot rename because item at '<workspace>\winre.wim' does not exist. The script logs Could not set up program lock at <path> : <error> - proceeding without single-instance protection; concurrent runs may collide earlier in the log when this happens. If you see this fatal exit, check the log for the lock-acquisition failure line and investigate why the lock could not be acquired. See deployment.md for the lock design and troubleshooting.md for the recovery procedure.catch block logs and exits 3. The v49 temporary WinRE Manager - Resume task’s persist flag is set by this path (the outer catch trigger), so an unhandled exception during a Repair or Restore leaves the resume task registered and the operation is resumed on the next boot or within the hour.Fatal exits do not write a state file. If a state file was written earlier in the run and the fatal exit occurs after that point, the state file is left as-is; on the next run, the fast path may fire if the state is now healthy, or the full-update path may re-run if it is not.
Special case for orchestration: exit code 3 with the log line FATAL: WinRE is not enabled at exit on a machine that no longer has a recovery partition indicates the pre-patch-5 failure mode. Do not retry automatically. Follow the recovery procedure in troubleshooting.md.
Second special case: exit code 3 with the log line Refusing to retry reagentc /enable indicates the enable-failure loop-breaker. Do not retry automatically — the same guard will fire on the next run because the state file still records the counter value. Resolve the underlying cause, delete the state file, and re-run. See troubleshooting.md for the diagnosis procedure.
Third special case: exit code 3 with the log line rollback restore hash verification failed or rollback restore failed on a v49 -Action Restore run indicates the transactional helper could not restore the previous WIM after a failed replacement. The machine’s WinRE WIM may be in an inconsistent state. Capture the full log and file a bug; the branch has not been exercised in the field.
Fourth special case: exit code 3 with the log line Restore failed at reagentc /setreimage: … on a v49 -Action Restore run indicates the WIM was replaced but reagentc was not re-registered. The state file, checkpoint, and deferral marker were deleted, and the resume task was preserved, so a subsequent repair run (or the resume task’s re-invocation) will re-attempt registration. Capture the full log for a bug report; the branch has not been exercised in the field.
An independently verified candidate and trusted operation record can outlive the current process. Code 1 retains them while enablement awaits reboot; code 2 can retain them after a pre-switch refusal with the old route preserved. Code 3 covers an unresolved transition or required persistence/integrity failure. A valid dedicated route followed by a state-write or journal-retirement failure must remain active; failure reporting does not authorize reverting it.
The pending record and candidate remain separate from DSI and ordinary checkpoints. Do not delete them to make a warning disappear. Resolve the cause, re-run Repair, and inspect the final registration, hash and capacity observations. No exit code by itself proves a successful recovery boot.
Deferring WinRE Manager: Windows is not in a normal-running state (Setup\State\ImageState=…). The VMD-query-indeterminate gate logs VMD hardware detection was indeterminate; deferring because the driver set cannot be safely determined.. The OS-fallback BitLocker gate logs OS-fallback deferred: C: could not be confirmed fully decrypted (Test-VolumeEncrypted=…) followed by the resolution guidance. The v45 pre-shrink deferral logs Dedicated replacement deferred before partition deletion (<Reason>). and, when the marker is written, Recorded retry-suppressing deferral for DesiredStateId <id>; …. The v47 race-detector abort at the Ensure-AdequateRecoveryPartition site logs Registered WinRE source changed during candidate preparation - aborting before /disable. Restoring <resize-target label> to its captured size; no partitions have been deleted.. The v47 race-detector abort at the Step 5 deployment site logs Registered WinRE source changed during candidate preparation - aborting before /disable. The old WinRE route remains intact; no partition changes have been made at this site.. The v47 strip-failure abort logs Strip stage failed - candidate rejected. Dismounting with -Discard and deferring before injection, export, partition work, or WinRE disable.. The three v49 source-ownership outcomes log their own distinct lines: Source-ownership decision: driver enumeration failed after 3 attempts: … - candidate rejected, Foreign source preserved byte-identically; assessing dedicated layout without strip, injection or export., and Never-downgrade invariant: discarding the candidate edits and preserving the original source bytes. The v49 storage-applicability gate refusal logs a line naming the candidate image path, the machine’s present SCSIAdapter-class devices, and the count of controllers with no matching INF. The concurrent-instance gate logs Another WinRE Manager instance is already running (program lock file is exclusively held). …. The offline-fallback gate logs Offline fallback: the machine requires a full update (state file is stale or unhealthy), but the driver manifest is unavailable. …. All of those, plus the four v48 deferral additions (the architecture-gate refusal, the intervening-anchor surplus rejection, the multi-intervening rejection, and the offline LocalInputsId mismatch) and the two v49 startup/gate additions (the native-boot VHDX fail-closed gate and the pre-deployment storage-applicability gate), are distinguishable by the log text alone. The v48 elevation-guard refusal exits EXIT_FATAL (code 3), not EXIT_WARNING, and its log signature is described in the EXIT_FATAL section above. The v49 restore /setreimage failure also exits EXIT_FATAL, with its own log signature in that section. The state timestamp is supporting evidence, not a unique outcome classifier: preserved-source work can defer before a state write, and a verified dedicated route can remain after a later persistence failure. Check the final route and pending record. The v49 restore mid-transformation failures additionally leave a WinRE Manager - Resume scheduled task registered — the presence of that task is a strong signal that a Repair or Restore run was interrupted rather than that it completed with a warning. The /enable failure path exits EXIT_WARNING and deletes the state file; the /setreimage failure path exits EXIT_FATAL and also deletes the state file.Target partition X/Y (Z:) is BitLocker-managed (state=…) - running manage-bde -off to decrypt and a confirmation line with the elapsed time when the decryption completes. If Set-RecoveryPartitionReadyForWinRE returned without decrypting, the log records Target partition X/Y (Z:) is already unencrypted - reagentc /enable can proceed.EnableFailureAttempts from the state file, or look for the Enable-only /enable failed (attempt N of 3) or Enable-only /enable refused with the BitLocker error after the target partition was confirmed unencrypted (attempt N of 3) log line.C:\Recovery\OEM\winre_partition_deferred.json. Its DesiredStateId and Since fields tell you the exact DSI under which the destructive sequence deferred, and the timestamp records when. The marker is not part of the deployment identity, and its presence does not change the exit code — but it is the reason a subsequent run may exit EXIT_WARNING without re-attempting the pre-shrink.Get-ScheduledTask -TaskName 'WinRE Manager - Resume' -ErrorAction SilentlyContinue. Live Repair and Restore attempt registration when a script path is available and staging checks pass. Patch 5 retains the task while a pending deployment or its recovery material remains unresolved; Restore failure handling, an unhandled exception and the compiled Ctrl+C signal can also request retention. A hard kill or reboot can leave the task registered because finally never runs. A clean verified completion normally removes it. Presence alone does not identify the failure; read the log and pending record. Do not delete the task or protected candidate to bypass recovery. Scriptless invocation cannot register the task. See the retention contract and resume troubleshooting.Acquired program lock at C:\ProgramData\OEM\Logs\WinREManager.lock when the lock was acquired, [DRY RUN] Skipping program lock - DryRun is read-only and safe to run concurrently with other instances under -DryRun, or Could not set up program lock at <path> : <error> - Backup may continue, but Repair and Restore require exclusive ownership on a non-contention failure. Live Repair and Restore refuse without the exclusive handle; Backup may continue.Strip: pre-strip third-party inventory: N package(s) followed by one line per package (Strip: <published INF> | <provider> | <version> | <original filename>), and then either Strip: image already has zero third-party drivers (no-op) or one Strip: removed <published INF> line per removal plus a final Strip: verified zero third-party drivers remaining after removing N package(s). The pre-strip inventory is the primary field-evidence mechanism for whether Windows Update ever delivers third-party driver packages inside a serviced WinRE image — see architecture.md — “The v47 rebuild pipeline” — “What the empirical observation settled”.Base WIM source selection: <reason> -> <path> on every full-update run. The reason names the branch: registered at least as new as LKG, registered older than LKG, metadata comparison indeterminate, no hash-validated LKG present, registered not usable, or GitHub cold-start.Manager-Owned, Manager-Lineage, Foreign-No-Drivers, Foreign-With-Drivers) before the strip stage runs. A Foreign-With-Drivers source is preserved as-is and the strip-and-reinject pipeline is skipped; the others proceed to the strip stage. This is the primary field-evidence mechanism for whether the manager is preserving a vendor-populated source instead of normalizing it.Never-downgrade invariant: discarding the candidate edits and preserving the original source bytes. precedes the per-driver detail lines.Storage applicability: Applicable=True, Controllers=N, Matched=N, Reason=…. On a candidate that fails, the log names the candidate image path, the machine’s storage controllers, and the count of controllers with no matching INF (Storage applicability: Applicable=False, Controllers=N, Matched=N, Reason=…). The gate is the last refusal before deployment; a machine that exits EXIT_WARNING from this gate has a fully prepared candidate that was not written to the active route./disable race detector rechecked the source, and what it found. The log records Captured registered-source fingerprint: location=<loc>, version=<ver>, hash=<hash> at the start of the rebuild, and one of the two recheck lines: Registered-source recheck at <site> : unchanged (location=<loc>, version=<ver>) on a clean recheck, or the abort line naming the changed field. The <site> is Ensure-AdequateRecoveryPartition or Step 5 deployment.backup.json write result; a restore records the backup directory, the backup.json contents, the resolved current route, and the transaction’s outcome. On a clean completion the resume task is not registered; on any of the three mid-transformation failure paths the resume task is preserved and the log names the specific failure.Remove-StrayRecoveryPartitions suppresses its entire sweep when the running OS is inside a known hypervisor (matched against Win32_ComputerSystem Manufacturer/Model via Test-RunningInVirtualMachine) or when the detection is indeterminate (fail closed). Suppression does not change the exit code — the run completes with the same exit code it would have had if the sweep had run and found no strays. The log line is Stray-recovery cleanup: skipping the non-OS-disk sweep because <reason>. On a physical machine the sweep runs as before, but any non-OS disk reported as File Backed Virtual is preserved individually with its own log line (Stray-recovery cleanup: preserving File Backed Virtual (mounted VHD/VHDX) disk <n> ...). If stray recovery partitions you expected to be deleted are still present, check the log for one of those lines first.For any of those details, read the log. See troubleshooting.md.
The pending-reboot path has its own exit logic. In order:
RepairAttempts is incremented before any other work. If the incremented value exceeds 3 (equivalently, the state file already records RepairAttempts >= 3), the run exits EXIT_FATAL immediately without attempting repair. This guard is a precondition on the whole pending-reboot path, not a post-condition on its outcome.DeployedDiskNumber / DeployedPartitionNumber, or C:\Recovery\WindowsRE for OS-fallback).Set-RecoveryPartitionReadyForWinRE on the recorded partition. If it returns $false — the target could not be made unencrypted within the timeout — defer with EXIT_WARNING immediately.Test-VolumeEncrypted. If it does not return exactly $false, defer with EXIT_WARNING immediately. The deferral logs Pending-reboot OS-fallback: C: could not be confirmed fully decrypted (Test-VolumeEncrypted=…) - deferring without changing C: BitLocker state. The script never modifies C:’s BitLocker state.reagentc /enable against the recorded path. If the retry succeeded and WinRE reports Enabled:
UsedOSFallback was carried over from the state file → EXIT_WARNING.nonFatalWarning was set → EXIT_WARNING.EXIT_SUCCESS.EXIT_REBOOT_REQUIRED.Note that PendingReboot and RepairAttempts are recorded in the state file before the exit, so a machine that exits with code 3 due to too many repair attempts still has a state file reflecting the current repair count.
The pending-reboot path writes the state file with LastEnableResult = "ok" and EnableFailureAttempts = 0 on the paths that reach a state write (successful enable, reboot-required enable). A machine that completes those paths therefore has its enable-failure counter reset — the pending-reboot path represents a different failure mode (registration did not complete after a reboot) and is tracked by the separate RepairAttempts counter. The target-preparation-failure path exits before the state write and leaves the counter preserved. The two counters are independent. A target-preparation failure on the pending-reboot path does not increment EnableFailureAttempts; the exclusion is deliberate, because immediately after a reboot the target partition’s encryption state may be transiently indeterminate, and the pending-reboot path is tracked exclusively by RepairAttempts.
Recommended orchestration policy:
| Code | Action |
|---|---|
| 0 | Record success. No further action. |
| 1 | Schedule a reboot at the next maintenance window. The next run will finish the registration. |
| 2 | Read the summary Why: field and the detailed warning case above. Backup can leave a usable verified WIM despite a sidecar failure. Repair warnings can mean preserved-image handling, a safe deferral, last-resort OS-fallback or unresolved pending work; inspect the actual route, state and pending record. Preservation alone does not establish an adequate or bootable recovery route. Retain an unresolved candidate, journal and resume task. |
| 3 | Investigate the fatal case above before retrying. A preflight/status refusal can occur before repair work; a deployment failure can leave the recovery route unavailable; a persistence failure can leave a verified new route intact. Use the log and actual registration to distinguish them. Preserve pending recovery material and any registered resume task, and resolve the reported query, provider, integrity or persistence failure. |
Do not use exit code 0 as the sole health signal. A machine that reached OS-fallback exits with 2, which is a legitimate “the machine is functional but the design goal was not achieved” signal. If your deployment policy requires dedicated recovery partitions, treat 2 as a soft failure and route it to a queue.
Do not configure retry loops that ignore the exit code and re-run unconditionally. None of the deferral states is made better by retrying — the same gate will fire on the next run. Wait until the underlying condition resolves (manage-bde -status C: reads a safe state on the OS-fallback route, the PnP enumeration error clears, the machine has finished OOBE, the pre-shrink constraint is freed, the anchor is extended, or the marker is cleared), then re-run. Six v47/v49-specific retry exceptions:
Source-ownership decision: driver enumeration failed after 3 attempts, the DISM WIM provider was persistently unavailable to the mounted image. Investigate the provider state before re-running; a mechanical retry may succeed if the failure was transient, or may hit the same wall.Never-downgrade invariant: candidate image would replace an existing storage driver with an older version, do not re-run without first investigating the manifest or OEM pack. The same candidate will be regenerated and the same downgrade detected on every retry until the stale driver reference is removed from the manifest or the pack is updated.requiredDevices patterns and the resolved pack’s INFs; a machine whose controller is missing from one or the other will keep deferring until the data is updated.For the enable-failure counter, do not retry blindly: the counter is designed to break a silent loop, and after three consecutive failures the loop-breaker fires and requires manual intervention. Investigate the enable failure itself rather than cycling the script. For the concurrent-instance deferral, the correct action is to wait; the other instance is already doing the work.
For a v49 restore that exits 2 with a WinRE Manager - Resume task present, do not intervene — the task will resume the operation on the next boot or within the hour. Deleting the task manually abandons the interrupted restore. If the task keeps reappearing after each attempt, the interrupted operation is failing in the same way every time; read the log around the failing step.
/disable race detector, the WIM_READY checkpoint’s source binding, and the metadata-based drift detector that together shape the v47 exit cases. “The v49 pipeline refinements” describes the source-ownership classification, the never-downgrade check, and the pre-deployment applicability gate that shape the v49 exit cases.DeployedWinREMetadata field (v47), the offline fallback’s residual risk, the LocalInputsId field (v48 patch 1), and the ForeignSourceAcceptedHash and LineageId fields (v49).