EnterpriseWindows

Upgrade and remove on Windows

How the standalone Windows deployment upgrades the hook agents run, how uninstall and purge clean up machine and per-user state, and what to do when they stop.

How the standalone Windows deployment upgrades and how it is removed. The commands are also on Install on Windows; fleet-wide upgrade and rollback are in Lifecycle.

Upgrade

Run /ensure with the newer Setup. It upgrades in place and keeps the config and state. It refuses an older version (downgrade_refused); see Roll back.

The hook during an upgrade

Agents start the hook from a folder named after the hook's own digest: C:\Program Files\Cisco\DefenseClaw\bin\hooks\<first 16 hex digits of its SHA-256>\defenseclaw-hook.exe, with defenseclaw-hook-guard.exe beside it. Every agent hook config DefenseClaw writes names that path, so an upgrade never replaces the program an agent starts.

  1. Setup copies the new hook and guard into a new folder and checks the bytes against the signed payload.
  2. Setup starts both once, checks that they report this release, and runs the managed Claude Code hook command on a test tool call. That call can leave one audit row for a Read of defenseclaw-hook-image-self-test.txt.
  3. Only then are the agent configs switched to the new folder: Codex during the run, the others on the guardian's first check after it. Each file is replaced in one step.
  4. The previous folder stays, so a session that read its hook command before the upgrade keeps starting a hook that exists. The hook accepts any image under this install's bin\hooks.
ResultMeaningWhat to do
hook_image_start_failed (exit 1603)The new hook or guard could not start, usually because application control or antivirus blocked the new folder. Setup rolled back; agents keep the installed hookAllow the install folder C:\Program Files\Cisco\DefenseClaw and everything under it, including bin\hooks\*, by path. A rule on one hook folder fails: its name changes with every release. The release is not code-signed, so a publisher rule cannot match it
hook_image_publish_busy (exit 1618)Another program, such as an antivirus scan, kept the new folder busy through every retry. Nothing switchedRetry
hook_image_not_staged (from verify)The current folder is missing or does not match. Agents run the copy at bin\defenseclaw-hook.exeRun /repair
machine_file_busyAnother program held a machine file open, so Setup removed no old folderClose the program and run the prune again
hook_rollback_copy_rederivedThe installed hook did not match the recorded digest, so Setup kept its own verified hook as the rollback copyNone; the warning names both digests

Rules aimed at one user or group

The start check runs under a filtered copy of Setup's token, not as an enrolled account. A WDAC, AppLocker or EDR rule that names one user or group is not checked at install. If that rule blocks the hook later, Claude Code and Codex run the tool call without a DefenseClaw decision or audit row, whatever hook_fail_mode is (a stopped pre-tool hook). Allow C:\Program Files\Cisco\DefenseClaw by path in every rule that applies to enrolled accounts, and after an upgrade on such a host make one agent call as an enrolled user and check its audit row.

Other facts:

  • bin\defenseclaw-hook.exe stays as a second copy with the current hook's bytes, for configs and sessions that still name it.
  • After a committed upgrade, Setup removes an older bin\hooks folder only when it is not the current or the replaced one, no hook config DefenseClaw wrote still names it, and a newer release replaced it at least 14 days ago. A folder whose hook is running is kept for a later upgrade.
  • While pruning, Setup reads each account's agent configs as SYSTEM and never follows a link (junction, symbolic link or mount point) under the account's home. Such a file is skipped and named (link_in_account_path). A link at C:\ProgramData\OpenAI\Codex or C:\ProgramData\Cursor owned by SYSTEM or Administrators stops the prune (link_at_machine_folder): replace it with a plain folder.
  • /repair, /ensure and the guardian do not replace a healthy hook. The guardian restores a changed or missing current hook from its protected copy.

A program that holds the hook open

While a program holds the hook file open without sharing it, no account can start the hook. On a standalone install the guardian, which runs as SYSTEM, ends such a hold by closing that handle in the signed-in user's process that owns it, after the hold lasts across two checks about 5 seconds apart. It never closes a handle in a protected, service or session 0 process, and it also watches the runtime files a hook start reads, such as machine-policy.json.

Every handle it closes, and every hold it could not end, writes a HIGH connector-hook-tampered audit row naming the program, process, account and file. A user who keeps re-opening the hook can keep it unavailable for most of the backoff (10 seconds, doubling to 5 minutes). A holder that shares deletion is swapped around instead of closed.

The full rules (which handles, which processes, audit-row delivery and limits) are in How the guardian ends a hold on the hook.

Accounts that are signed out or hold a foreign hook file

An upgrade activates even when some user targets fail in the new guardian's first reconcile: an account that is signed out, or a Copilot hook file with handlers DefenseClaw did not write. The services run, the machine policy is enforced and every other account is protected.

  • Each such target is named in enrollment with its reason, and in the lifecycle log as defenseclaw_degraded.
  • A signed-out account counts as pending until its next sign-in.
  • Any other failed target counts in enrollment.failed and makes coverage_complete false until the guardian repairs it. /ensure again changes nothing and exits 0; enterprise windows verify still fails.
  • A rollback or recovery that cannot start the restored release ready starts it again with its previous service set and says so in the error.

Remove

With Setup, or with the installed CLI:

& .\DefenseClawSetup-Enterprise-Standalone-x64.exe /uninstall JSON=1
& 'C:\Program Files\Cisco\DefenseClaw\bin\defenseclaw.exe' enterprise windows uninstall --profile standalone --json

Run per-user cleanup as LocalSystem (Run Setup as LocalSystem) while the accounts have a connected session. Run the CLI uninstall with defenseclaw.exe; other installed binaries refuse it (1639).

What an uninstall removes

ItemPlain uninstallWith PURGE=1 (--purge)
Services, binaries, hook runtimeRemovedRemoved
Machine state under C:\ProgramData\Cisco\DefenseClaw (config, secrets, data, service logs)RemovedRemoved
Hook registrations and machine policy entries (for GitHub Copilot, the policy.d drop-in and enabledPlugins["defenseclaw@defenseclaw"] in %ProgramFiles%\GitHubCopilot\managed-settings.json)RemovedRemoved
Marker key, Add/Remove Programs entry, a DisableSelfUpdate value the lifecycle wroteRemovedRemoved
Empty vendor folders DefenseClaw created (C:\ProgramData\Cisco, C:\Program Files\Cisco, C:\ProgramData\Cursor, C:\ProgramData\OpenAI\Codex, C:\Program Files\ClaudeCode)Removed once nothing of the deployment is leftSame
Files the managed runtime wrote in each enrolled account's %USERPROFILE%\.defenseclawRemoved (see below)Removed with the whole folder
foreign-hooks-backup, .defenseclaw.rollback-<random> copies, launchers and binaries in %USERPROFILE%\.local\binKeptRemoved. Copy foreign-hooks-backup first if the account wants those hooks back
Lifecycle lock (C:\ProgramData\Cisco\DefenseClaw-Lifecycle)Setup uninstall removes it; a plain CLI uninstall leaves it (harmless)Removed
Lifecycle log in %WINDIR%\Logs\DefenseClawKeptKept

A plain uninstall run as LocalSystem removes from each enrolled account's %USERPROFILE%\.defenseclaw what the managed runtime wrote: hooks, logs, hook_contract_lock.json and its lock, inventory.db, foreign-hook-env.json, foreign-hook-sessions, agent_selection.json, the connectors' lock files and the emptied connector_backups folders. The account's own files, foreign-hooks-backup and acp stay, with an owner-private access list, and the result names them in user_state_remaining. A folder that holds a per-user install (config.yaml, audit.db, .venv or installer) is not changed.

Per-user registrations

Uninstall revokes every enrollment, then removes DefenseClaw's registrations and plugins (Amp, Antigravity, Devin, Hermes, Kiro, OpenCode, a Copilot user hook file) from the agent config of users with an active session, running as each user.

AccountWhat happens
Signed in with a connected session, uninstall as LocalSystemRegistrations removed
Signed out, or disconnected (query user shows Disc)Keeps its registrations and .defenseclaw; named in user_registrations_pending (and per_user_state_remaining for a purge, which still exits 0)
Any account, when the uninstall runs from an elevated prompt or Add/Remove ProgramsNone removed (user_registrations_pending). Acting as a user needs LocalSystem
Failureuser_registrations_failed

An older Claude Code per-user hook in %USERPROFILE%\.claude\settings.json is removed exactly; a changed one is kept with claude_settings_hook_left.

What stays is inert. The OpenCode and Amp plugins stop enforcing, and the Devin, Hermes, Antigravity, Kiro and Copilot hooks point at the removed defenseclaw-hook.exe, so each call fails to start and none of those agents blocks on it (Hook process control).

Folders DefenseClaw created

Setup records each folder it creates in C:\ProgramData\Cisco\DefenseClaw-Lifecycle\created-folders. Uninstall removes a recorded folder only when it is empty, still administrator-owned and only administrators can change it or its parent. A folder that existed before the install, or holds another program's files, stays, and so does every folder above it. A kept folder keeps its record, so the next purge tries again; the result names it in created_folders_kept.

  • Shared machine folders (C:\Program Files\ClaudeCode\managed-settings.d, Codex's requirements.toml) stay while they hold anything else. Codex's file can hold your own keys, so a purge with no deployment record leaves it, and the next /ensure adopts it.
  • A link or junction at a vendor folder, or on the path to one, is never followed, changed or removed by uninstall. Nothing behind it is read or deleted. The link is named once in machine_state_kept, and the rest of the uninstall completes. For Codex this means a requirement behind the link may still name the removed hook: check the policy behind a link you made.
  • The machine policy folders DefenseClaw writes for GitHub Copilot, OpenCode and Devin under C:\ProgramData differ: a link a standard user made there is removed (the link only); a link an administrator made stays and is named.
  • Install, ensure, repair and the Codex removal stop with an error when a link sits at a vendor folder, except that a standard user's link at the Copilot, OpenCode or Devin policy folder is removed first.
  • A link inside C:\ProgramData\Cisco\DefenseClaw (for example at secrets) is removed as a link, never followed. A link at that folder itself, or one Setup cannot remove, stops the uninstall with 1603 (state_invalid) and names the command that removes only the link.

Folder permissions stay

While an account is enrolled, the guardian gives the agent folders and files that hold DefenseClaw's registrations (for example %USERPROFILE%\.config, .config\amp\plugins, .config\opencode\plugins, .codex and .claude\settings.json) an explicit access list that does not inherit from the profile. Uninstall removes DefenseClaw's entries but keeps that list.

The account keeps full access to its files, but new items do not inherit from the profile and Administrators are not on the list. To return one to the profile's permissions, run icacls "<folder or file>" /reset as LocalSystem. (Get-Acl "<path>").AreAccessRulesProtected is True for each one that still has the list.

When an uninstall stops

On a computer without DefenseClaw, uninstall succeeds and changes nothing.