Skip to content

Self-hosting OpenClaw on Windows (PowerShell, WSL2, NSSM)

Install OpenClaw on Windows 11 — PowerShell one-liner, the WSL2 alternative when native Windows misbehaves, NSSM as a service supervisor, log paths under %USERPROFILE%, and a verification checklist.

You want OpenClaw — the personal AI agent that actually does things (openclaw.ai) — on a Windows 11 machine that is your daily driver, not a Linux box hiding under your desk. The PowerShell installer exists, the npm package installs cleanly, and the agent will run, but the Windows side of the story has two paths: native Windows with a Scheduled Task or NSSM as the supervisor, or WSL2 with the same systemd unit you would use on Ubuntu. This walks both, picks a default, and gives you the verification commands.

Scenario

Windows 11 Pro or Home, you log in with a local or Microsoft account, the machine is awake most of the day. You want the agent persistent across reboots, running as your user (not LocalSystem), and you want it back automatically after a Windows Update reboot at 3 AM. You are comfortable in PowerShell; you may or may not already have WSL2 installed.

Outcome and prereqs

When this is done you’ll have:

  • OpenClaw installed globally via the PowerShell one-liner or npm i -g openclaw.
  • A populated %USERPROFILE%\.openclaw\ directory: openclaw.json, .env, workspace\, memory\, and logs\.
  • The gateway running on 127.0.0.1:18789 and surviving sign-out and reboots, via either a Scheduled Task (default), NSSM service (preferred for unattended machines), or a WSL2 user-systemd unit.
  • A clean openclaw doctor and openclaw gateway status output.

Prereqs:

  • Windows 10 22H2 or Windows 11. Older builds work but you will fight Defender SmartScreen more than is reasonable.
  • PowerShell 7+ recommended. The bundled Windows PowerShell 5.1 works for the install but not for some of the diagnostic one-liners later.
  • Administrator rights for one step (NSSM service install) and for WSL2 if you go that route.
  • An API key for at least one of Anthropic Claude or OpenAI, or a local model server reachable from the host.
  • ~3 GB free disk for Node, the global npm tree, and a typical first-month workspace.

Time and resource footprint

About 25 minutes attended. Steady-state on a modern Intel/AMD laptop the gateway sits around 250 MB resident, idle CPU near zero. Each agent turn spikes CPU during the model round trip; the model itself runs in the upstream provider’s cloud or in your local Ollama/LM Studio. WSL2 adds a few hundred MB to the WSL VM but nothing material.

Step 1 — Install Node 24

The OpenClaw README pins Node 24 as the recommended floor, with 22.16+ as the supported minimum. Three paths:

PowerShell with winget (simple, system-wide):

winget install -e --id OpenJS.NodeJS.LTS
node --version    # v22.x or v24.x depending on what LTS resolves to

If winget resolves to Node 22.x and you want 24.x explicitly:

winget install -e --id OpenJS.NodeJS
node --version    # v24.x.x

Chocolatey:

# As Administrator
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = `
  [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

choco install -y nodejs --version=24.0.0

nvm-windows (per-user, multiple Node versions):

Download the latest installer from github.com/coreybutler/nvm-windows/releases, run it, then in a new shell:

nvm install 24.0.0
nvm use 24.0.0
node --version    # v24.0.0

nvm-windows is the safest path if you already do JavaScript dev with other Node versions on the same box. Mix winget-installed Node with nvm-installed Node and you will spend an hour figuring out which one your npm i -g actually wrote to.

Step 2 — Install OpenClaw

Two equivalent options. The PowerShell one-liner is the canonical install path on openclaw.ai:

iwr -useb https://openclaw.ai/install.ps1 | iex

If you want to skip the interactive onboard at the end (for example, you are scripting):

& ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -NoOnboard

Or run npm directly once Node is on PATH:

npm i -g openclaw
openclaw --version

If openclaw is not found after install, the global npm prefix is not on your PATH. npm config get prefix shows the directory; add <prefix> (not <prefix>\bin, Windows is different) to your user PATH environment variable via System Properties, then open a fresh shell.

Step 3 — Onboard

openclaw onboard

The onboarding flow asks the same three things it does on macOS and Linux: default model (anthropic/claude-sonnet-4-5, openai/gpt-5, etc.), the API key, and whether to install the user daemon. On Windows the daemon flag wires a Scheduled Task by default, with a fallback to a Startup-folder shortcut if task creation is denied by policy. The OpenClaw README documents both paths.

After onboarding, the layout under %USERPROFILE%\.openclaw\ is the same as every other platform:

%USERPROFILE%\.openclaw\
├── openclaw.json
├── .env
├── workspace\
│   ├── AGENTS.md
│   ├── SOUL.md
│   ├── TOOLS.md
│   └── skills\
├── memory\
└── logs\

Lock down .env. Windows ACLs are not POSIX permissions, but you can deny inheritance and grant only the current user:

$envPath = "$env:USERPROFILE\.openclaw\.env"
icacls $envPath /inheritance:r
icacls $envPath /grant:r "$env:USERNAME:(R,W)"
icacls $envPath

The file should now show only your user with read/write. A minimal openclaw.json (OpenClaw README):

{
  "agent": {
    "model": "anthropic/claude-sonnet-4-5"
  }
}

Step 4 — Foreground first run

openclaw gateway --port 18789 --verbose

You should see gateway listening on 127.0.0.1:18789 and a model-handshake confirmation. In another PowerShell window:

openclaw agent --message "What is my Windows build?" --thinking high

The agent should run a real PowerShell command like [System.Environment]::OSVersion or query the registry under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion, then summarize. If it returns a guess, the shell-tool permission is not wired — re-run openclaw onboard and explicitly accept shell access.

Ctrl-C the gateway and pick one of the supervisor paths below.

Step 5 — Pick a supervisor

There are three reasonable supervisor patterns on Windows. Pick one and stick with it.

Option A: Scheduled Task (default, what --install-daemon creates)

This is what openclaw onboard --install-daemon already created if you accepted the daemon during onboarding. To inspect it:

Get-ScheduledTask -TaskName "OpenClaw Gateway" | Format-List
Get-ScheduledTaskInfo -TaskName "OpenClaw Gateway"

You should see LastRunTime recent and LastTaskResult of 0. If you want to recreate it by hand (for example, you skipped --install-daemon and want full control):

$action = New-ScheduledTaskAction `
  -Execute "C:\Program Files\nodejs\node.exe" `
  -Argument "`"$env:APPDATA\npm\node_modules\openclaw\bin\openclaw.js`" gateway --port 18789" `
  -WorkingDirectory $env:USERPROFILE

$trigger = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME

$settings = New-ScheduledTaskSettingsSet `
  -AllowStartIfOnBatteries `
  -DontStopIfGoingOnBatteries `
  -RestartCount 3 `
  -RestartInterval (New-TimeSpan -Minutes 1) `
  -StartWhenAvailable

$principal = New-ScheduledTaskPrincipal `
  -UserId $env:USERNAME `
  -LogonType Interactive `
  -RunLevel Limited

Register-ScheduledTask -TaskName "OpenClaw Gateway" `
  -Action $action -Trigger $trigger `
  -Settings $settings -Principal $principal -Force

Adjust the node.exe path if your install is somewhere else — (Get-Command node).Source tells you. Scheduled Tasks restart the agent at user logon, not at boot, and they run as you. That is exactly what you want for a desktop. If the machine is more of a workstation that should be agent-on before anyone signs in, jump to Option B.

Option B: NSSM service (machine-on at boot, no logged-in user required)

NSSM (the Non-Sucking Service Manager — its actual name) wraps a console application as a real Windows service. It is the standard way to run a Node.js daemon as a service on Windows. Install it via Chocolatey or by dropping nssm.exe from nssm.cc into C:\Program Files\nssm\.

# As Administrator
choco install -y nssm

nssm install OpenClawGateway "C:\Program Files\nodejs\node.exe" `
  "`"$env:APPDATA\npm\node_modules\openclaw\bin\openclaw.js`" gateway --port 18789"

nssm set OpenClawGateway AppDirectory "$env:USERPROFILE"
nssm set OpenClawGateway AppEnvironmentExtra `
  "HOME=$env:USERPROFILE" `
  "USERPROFILE=$env:USERPROFILE" `
  "PATH=C:\Program Files\nodejs;%PATH%"

nssm set OpenClawGateway AppStdout "$env:USERPROFILE\.openclaw\logs\gateway.out.log"
nssm set OpenClawGateway AppStderr "$env:USERPROFILE\.openclaw\logs\gateway.err.log"
nssm set OpenClawGateway AppRotateFiles 1
nssm set OpenClawGateway AppRotateBytes 10485760

# Run as your user so the agent has your file ACLs, not LocalSystem's
nssm set OpenClawGateway ObjectName ".\$env:USERNAME" "<your-password>"

nssm set OpenClawGateway AppExit Default Restart
nssm set OpenClawGateway AppRestartDelay 5000

nssm set OpenClawGateway Start SERVICE_AUTO_START
nssm start OpenClawGateway

nssm status OpenClawGateway

AppExit Default Restart plus AppRestartDelay 5000 gives you a five-second back-off restart on crash, which is the same pattern as Restart=on-failure RestartSec=5 on systemd. The ObjectName line is the one almost everyone gets wrong on first try — if you leave it as LocalSystem, the agent will not have access to %USERPROFILE%\.openclaw\ and will refuse to start. NSSM service-creation flags are documented at nssm.cc/usage.

Option C: WSL2 (when native Windows fights you)

If you keep hitting Defender, Group Policy, or path-length issues, the WSL2 path is the same as the Linux desktop guide. Briefly:

wsl --install -d Ubuntu-24.04

Reboot. Open the Ubuntu shell, then follow Self-hosting OpenClaw on Linux desktop (Ubuntu and Fedora) from Step 1. The user-systemd unit, loginctl enable-linger, and journalctl --user -u openclaw all behave the same inside WSL2 as on bare Linux. The catch is that WSL2 must be running for the agent to be reachable; configure WSL to start on Windows login via the WSL2 settings or a Scheduled Task that runs wsl -d Ubuntu-24.04 -- true at logon. The OpenClaw README is explicit that both native Windows and WSL2 are supported, with WSL2 noted as more stable on edge cases.

Verification

openclaw doctor
openclaw gateway status

openclaw doctor checks Node version, gateway reachability, configured providers, API-key validity, and chat-channel pairings. A healthy run ends with green checks on every row.

Confirm the listener:

Get-NetTCPConnection -LocalPort 18789 -State Listen
# LocalAddress  LocalPort  RemoteAddress  RemotePort  State   OwningProcess
# 127.0.0.1     18789      0.0.0.0        0           Listen  ####

Tail the log:

Get-Content "$env:USERPROFILE\.openclaw\logs\gateway.out.log" -Tail 50 -Wait

Smoke-test the full stack:

openclaw agent --message "List the three largest files under my Downloads folder and summarize them"

Kill the Node PID, watch the supervisor restart it within five seconds (NSSM) or at the next logon (Scheduled Task).

Rollback

# If you used NSSM
nssm stop OpenClawGateway
nssm remove OpenClawGateway confirm

# If you used Scheduled Task
Unregister-ScheduledTask -TaskName "OpenClaw Gateway" -Confirm:$false

# Remove the global package
npm uninstall -g openclaw

# Archive state in case you want to come back
$archive = "$env:USERPROFILE\.openclaw.disabled.$(Get-Date -Format yyyy-MM-dd)"
Move-Item "$env:USERPROFILE\.openclaw" $archive

Troubleshooting

iwr fails with “request was aborted: could not create SSL/TLS secure channel”. Windows PowerShell 5.1 defaults to TLS 1.0/1.1. Force TLS 1.2 first:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
iwr -useb https://openclaw.ai/install.ps1 | iex

openclaw not found after install. The global npm prefix is not on PATH. Run npm config get prefix — typically C:\Users\<you>\AppData\Roaming\npm. Add that directory (not its bin\ subfolder; Windows does not use one) to your user PATH and restart the shell.

NSSM service starts and immediately stops. Almost always ObjectName set to LocalSystem with no access to %USERPROFILE%\.openclaw\. Set ObjectName to .\<your-username> with your password and restart. Confirm via the failed-to-start lines in gateway.err.log.

Defender SmartScreen blocks the install script. Right-click the .ps1 you saved → Properties → Unblock, then re-run. Or pipe through -ExecutionPolicy Bypass:

powershell.exe -ExecutionPolicy Bypass -Command "iwr -useb https://openclaw.ai/install.ps1 | iex"

Port 18789 already in use. Another OpenClaw instance, or you ran openclaw gateway twice. Get-NetTCPConnection -LocalPort 18789 -State Listen shows the PID; Stop-Process -Id <pid>.

Agent runs but cannot open Edge or Chrome. Browser automation needs Playwright’s bundled Chromium or a path to your installed browser. openclaw doctor reports the gap. npx playwright install chromium (run as your user, not Administrator) fixes most cases.

WSL2 agent unreachable from Windows host. WSL2 puts the Linux side on a virtual NIC. Reach it via localhost:18789 from Windows (WSL2 forwards localhost by default on recent builds) or set the gateway bind explicitly to 0.0.0.0 inside the WSL VM only and use the VM IP. Do not expose the WSL VM to the LAN.

Production-readiness

For a personal Windows machine, “production” means: the gateway survives Windows Updates, you have your config and memory backed up, and openclaw doctor runs green after every major Windows feature release. A short checklist:

  • %USERPROFILE%\.openclaw\ included in your File History or restic backup target. Skip logs\.
  • A monthly openclaw doctor reminder. Windows feature updates occasionally relocate the Node install path and break your supervisor’s hardcoded executable path.
  • API-key rotation calendar.
  • If you used NSSM with ObjectName=.\<user>, update the stored password whenever you change your Windows password (nssm set OpenClawGateway ObjectName ".\<user>" "<new-password>").
  • Telegram/WhatsApp/Signal pairings re-verified after each major OpenClaw release.

For teams that want this hardened on engineer workstations across a Windows fleet, talk to a senior operator at Stack Harbor about your self-hosted OpenClaw rollout.

Sources

  • OpenClaw home and PowerShell installer — https://openclaw.ai.
  • OpenClaw README, install commands, daemon flags — https://github.com/openclaw/openclaw.
  • NSSM usage and parameter reference — https://nssm.cc/usage.
  • PowerShell Scheduled Tasks cmdlets — https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/.
  • WSL2 install and configuration — https://learn.microsoft.com/en-us/windows/wsl/install.
  • nvm-windows — https://github.com/coreybutler/nvm-windows.

Last verified on OpenClaw current (May 2026).