Skip to content

Safety and Reversibility

Randy Northrup edited this page Nov 8, 2026 · 2 revisions

Safety and Reversibility

Open the Windows runs with administrator rights and changes the operating system, so safety and reversibility are the product. This page explains how a change is made, checked, undone and recorded, and what the engine refuses to do whatever it is asked.

How an apply run works

The desktop app and the command line use the same engine, and every run follows these steps:

  1. Plan. The engine reads the current state of every selected entry and decides what to do with each one: apply it, skip it (already in place), leave it (managed by your organisation), skip it (not applicable here), block it (risk not allowed, or a dependency missing), or refuse it (a safety rule forbids it). Entries are ordered by their dependencies. If two selected entries conflict, the whole run is rejected before anything changes.
  2. Nothing to do? If no entry needs a change, the run ends here: no journal, no restore point.
  3. Pre-flight. The run is blocked if the session is not elevated (machine and all-users runs), the OS is not supported, a reboot is pending from earlier servicing, Windows setup (OOBE) is still running, or the PC is in Safe Mode. A running Windows servicing session (TrustedInstaller) is only a warning.
  4. Run lock. Only one apply, revert or recovery runs at a time on a PC, whether it comes from the desktop app, the command line or the SYSTEM task. A run waits up to 30 seconds for another to finish.
  5. Crash recovery. Any earlier run that a crash or power loss interrupted is settled first (see below).
  6. Restore point. A System Restore point is requested, unless you turned that off.
  7. Journal first. The prior state of every action is written to the journal before the first change.
  8. Apply and verify. Each action is applied and then read back to confirm it took. The journal is updated after every action.
  9. Roll back on failure. If any action fails, does not verify, or the journal cannot be updated, every action of the run that was applied or part-applied is restored, newest first.
  10. Finish. The run is recorded as Completed, RolledBack or Failed, with the restart it needs (none, Explorer restart, sign-out or reboot). If you asked for it, Explorer restarts in the signed-in user's own session.

Preview any run first: --what-if on the command line, or the preview step of the desktop app's review-and-apply dialog.

Verification

After each action is written, the engine reads the setting back and compares it with what it should be. A mismatch counts as a failure and rolls the run back, so a setting that does not stick is never reported as applied.

Rollback

Rollback happens automatically inside a failed run. It restores, in reverse order:

  • every action that was applied;
  • every action that failed part-way (its prior value was captured before the write);
  • after a crash, the action that was in flight.
Run state Meaning
RolledBack The run failed and everything it changed was put back
Failed The run failed and could not be fully rolled back; the journal is the recovery record

Some changes cannot be put back automatically, for example a removed app. Those are reported as NotReversible instead of being claimed undone. For a removed app, the entry's action names how to get it back (otw catalog show <id>).

Revert

Revert restores the exact state captured before an earlier run. A revert is itself a journaled run, so it shows in History and can be reverted too.

What to undo Command line Desktop app (History)
A whole run otw revert <run-id> or otw revert last Revert run…
One entry of a run (new in v0.3.0) otw revert <run-id> --entry <id> (repeatable) Revert entry…
Everything the tool changed (new in v0.3.0) otw revert --all Undo everything…

last means the newest run whose journal verifies. --all reverts every run that is not already reverted, newest first, so later changes are unwound before the earlier ones they built on.

Before changing anything, revert checks that:

  • the run's journal verifies (see Journal and integrity);
  • the run has not already been reverted;
  • no later run changed any of the same settings;
  • the run finished (a run still marked in progress is settled by crash recovery instead);
  • every value it would restore passes the code-level safety rules.

If a check fails, nothing is changed and the reason is shown:

Message What to do
Run <id> was already reverted; pass --force to revert it again. Nothing, or use --force
Run <id> (<profile>, <time>) changed some of the same settings later; reverting would overwrite them. Revert that run first, or pass --force. Revert the later run first, or use --force
Run <id> did not finish; the next apply or revert recovers it automatically. Run any apply or revert

--force (command line only, new in v0.3.0) skips the "already reverted" and "later run" checks. It never skips the journal and safety checks.

Revert also loads the registry hives of users who have signed out since an all-users run, so their settings are restored too, and it starts again a service the apply had stopped.

A revert run cannot itself be reverted (new in v0.3.0): that would re-apply the original changes without their plan, gates or confirmations. Apply the profile again instead. otw revert last therefore always picks the newest apply run.

Journal and integrity

Item Location
Machine journal %ProgramData%\OpenTheWindows\journal, one file per run named <yyyyMMdd-HHmmss>-<runId>.json
Journal key %ProgramData%\OpenTheWindows\keys (administrators and SYSTEM only)
Per-user journal %LocalAppData%\OpenTheWindows\journal, for otw remediate --user-scope runs that change only the caller's own settings

Each machine journal is sealed with an HMAC-SHA256 under a 256-bit key that only administrators and SYSTEM can read. Every write goes to a temporary file that is flushed and then moved over the journal, so a crash leaves the previous record or the new one, never a torn file. Before any revert, the journal's MAC and its file owner are checked.

Integrity Desktop app label Meaning
Verified Verified The MAC (or hash) checks out and the file is owned by an administrator or SYSTEM
Unverified Not yet verified The record parsed, but this unelevated process cannot read the key. Revert, which runs elevated, always verifies.
Tampered Journal does not verify The MAC, hash or owner does not check out. Never replayed.
Unreadable Journal unreadable The file could not be read or parsed. Never replayed.

otw history --json includes each run's integrity.

The data folder %ProgramData%\OpenTheWindows is kept owned by Administrators and writable only by Administrators and SYSTEM; standard users can read it, except keys. An elevated run repairs the folders (removing links and files a non-administrator planted); an unelevated run refuses a folder that is not secured.

Restore points

Before an apply that will change something, the engine requests a System Restore point named Open the Windows: apply <profile>.

Turn it off How
One command-line run --no-restore-point
A profile "restorePoint": false in its options
The desktop app Settings > Create a System Restore point before applying

The run continues whatever happens to the restore point, and reports its status:

Status Meaning
Created A restore point was created and its existence verified
Skipped24h Windows declined because one was created within its frequency window (24 hours by default)
Disabled System Restore is turned off for the system drive
Failed The request failed for another reason
NotRequested No restore point was asked for

Windows Update pauses, feature-update holds and startup-app changes are small, journaled runs and do not request a restore point.

Run lock and crash recovery

Apply, revert and recovery are serialised machine-wide, so the desktop app, the command line and the SYSTEM task never interleave. If another run holds the lock for more than 30 seconds, the new run stops with Another apply or revert is running on this machine; try again when it finishes.

A run interrupted by a crash or power loss is settled before the next apply or revert: it is rolled back to its pre-run state, or marked completed if every action had finished.

Code-level refusals

These rules are built into the engine. They hold for the built-in catalogue, for extra catalogue files loaded with --catalog-dir, for profiles, and for journals replayed by revert. An entry that breaks one is shown as Refused and never applied, and the refusal is audited (Event 4000).

Protected services. The engine never changes the start configuration of services Windows needs for servicing, security, logging, licensing, identity, networking and the shell. Among them: WaaSMedicSvc, wuauserv, UsoSvc, DoSvc, BITS, TrustedInstaller, SecurityHealthService, WinDefend, WdNisSvc, Sense, wscsvc, MpsSvc, BFE, EventLog, CryptSvc and Schedule.

Protected scheduled tasks. Tasks under these folders are never disabled (enabling is allowed): WindowsUpdate, UpdateOrchestrator, WaaSMedic, InstallService, Windows Defender, ExploitGuard, SoftwareProtectionPlatform, TPM and BitLocker, all under \Microsoft\Windows\.

Protected registry locations. No write or delete, in any direction, under code-execution and persistence hooks: Image File Execution Options, Run and RunOnce keys, the Winlogon shell values, LSA security packages, COM server paths, service binary paths and accounts, Defender exclusions and signature-update settings, and the hosts-file path.

Never weaken a control. No apply of a value that turns off UAC, Microsoft Defender, SmartScreen or the Windows Firewall, or that blocks access to Windows Update. A revert may still put back exactly what the machine had before.

Defender preferences. No Defender preference that disables a protection (for example real-time monitoring or script scanning) may be set.

Commands. A catalogue command may only run powercfg, auditpol or fsutil, each with exact argument shapes. Security-policy values must be plain integers.

Untrusted executables. otw task install and the all-users logon fallback refuse to register an otw.exe that a non-administrator could replace or side-load.

Managed settings (MDM and Group Policy)

The engine never fights your organisation's management.

How a setting is detected as managed:

  • A value recorded in the Local Group Policy (Registry.pol) is managed by Group Policy, unless Open the Windows wrote it and still owns it. An ownership ledger records the policy values this product wrote, so switching profiles and fixing drift keep working.
  • On a device enrolled in MDM (with a management server) or joined to a domain, a live policy value that is neither in the Local GPO nor owned by this product came from the organisation and is managed too.

What happens to a managed setting:

Where Behaviour
Scan A managed setting that already has the wanted value is reported as Managed and is not drift. A managed setting with a different value is reported as drift, because the machine really differs.
Apply (command line) Skipped as Managed, unless --break-glass is given. Break-glass overrides are audited as Event 4001.
Remediate and the scheduled task Always skipped; remediate never uses break-glass
Desktop app Always skipped (shown as Managed by policy)
Windows Update pause or hold Nothing changes and the command exits with 6 (new in v0.3.0); the desktop app's Updates page is read-only

How this product writes policy values: through the Local Group Policy object, so they are recorded in Registry.pol and survive gpupdate, and mirrored into the live registry for immediate effect. Windows Home has no Group Policy engine, so there policy values are written to the live policy key directly.

Whose settings change

  • Per-user settings are written to the signed-in (interactive) user's registry hive, never to the elevating administrator's own hive by mistake.
  • Under the SYSTEM task or an SSH logon, the console user is targeted.
  • When nobody is signed in, per-user entries are reported not applicable instead of failing the run.
  • An all-users profile also loads the hives of users who are signed out and applies to them. On the command line it then registers a logon fallback, so those users, and users added later, are brought in line at their next sign-in. See Profiles.
  • An Explorer restart happens in the target user's own session (Remote Desktop included), never in another user's.

Audit trail

Every run, refusal, rollback and break-glass is written to:

  • the Windows Event Log (log OpenTheWindows, source OTW), when the source is registered;
  • monthly JSON-lines files, %ProgramData%\OpenTheWindows\audit\otw-<yyyyMM>.jsonl.

The JSON-lines trail is written even when the Event Log source is not available. Event ids are listed on Enterprise Deployment.

Clone this wiki locally