DEV Community

Deep Halder
Deep Halder

Posted on

I Built a Windows Auto-Installer for OpenClaw (So You Don't Suffer Like I Did)

OpenClaw Challenge Submission 🦞

Submitted for the DEV.to OpenClaw Challenge — OpenClaw in Action prompt

I spent 3 days getting OpenClaw running on Windows 11.
Three. Days.
Not because the tool is bad — but because Windows has some specific gotchas that nobody had documented yet. Old API keys hiding in environment variables. Device pairing errors. Token limit walls. Gateway crashes.
So I did what any frustrated developer does: I turned the pain into a tool.
Meet install-openclaw.ps1 — a one-click PowerShell installer that handles everything automatically.

🤔 What Problem Does It Solve?
Getting OpenClaw running on Windows involves:

Checking Node.js is installed
Choosing a safe install directory
Installing OpenClaw globally via npm
Clearing old API keys from Windows environment variables (the sneaky one)
Choosing and configuring an AI provider
Starting the gateway
Finding your auth token

My installer handles all of them automatically.

✨ Features

✅ Auto-detects Node.js
✅ Lets you choose your install drive
✅ Automatically clears old API key environment variables
✅ Supports Groq, OpenRouter, and Google Gemini
✅ Starts the gateway automatically
✅ Shows your token and exact commands to connect
✅ Warns you about common mistakes

🚀 How to Use It
Step 1 — Download install-openclaw.ps1
Step 2 — Right-click → Run with PowerShell
Step 3 — Follow the prompts and you're done!

💡 The Most Important Fix: Environment Variables
The sneakiest Windows bug: if you've ever set an API key as a Windows environment variable, it will silently override your OpenClaw config file — even after you update the config.
Check it manually:
powershellecho $env:GROQ_API_KEY
Clear it permanently:
powershell[System.Environment]::SetEnvironmentVariable("GROQ_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("GROQ_API_KEY", $null, "Machine")

📥 The Full Script

If PowerShell blocks the script, run this first:
powershellSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

powershell# OpenClaw Windows Auto-Installer

Created by Deep — based on 3 days of real troubleshooting

$ErrorActionPreference = "SilentlyContinue"

function Write-Green { param($msg) Write-Host $msg -ForegroundColor Green }
function Write-Yellow { param($msg) Write-Host $msg -ForegroundColor Yellow }
function Write-Red { param($msg) Write-Host $msg -ForegroundColor Red }
function Write-Cyan { param($msg) Write-Host $msg -ForegroundColor Cyan }

Clear-Host
Write-Cyan "=============================================="
Write-Cyan " 🦞 OpenClaw Windows Auto-Installer 🦞"
Write-Cyan " By Deep | DEV.to OpenClaw Challenge 2026"
Write-Cyan "=============================================="
Write-Host ""

Write-Yellow "[ Step 1/7 ] Checking Node.js..."
$node = Get-Command node -ErrorAction SilentlyContinue
if (-not $node) {
Write-Red " ✗ Node.js not found!"
Write-Host " Please install Node.js LTS from https://nodejs.org"
Read-Host " Press Enter to exit"
exit 1
}
Write-Green " ✓ Node.js found: $(node --version)"

Write-Yellow "[ Step 2/7 ] Choosing install directory..."
$defaultDir = "D:\OpenClaw"
if (-not (Test-Path "D:\")) { $defaultDir = "C:\OpenClaw" }
$userDir = Read-Host " Press Enter for $defaultDir or type a custom path"
if ($userDir -ne "") { $defaultDir = $userDir }
if (-not (Test-Path $defaultDir)) { New-Item -ItemType Directory -Path $defaultDir -Force | Out-Null }
Set-Location $defaultDir
Write-Green " ✓ Using: $defaultDir"

Write-Yellow "[ Step 3/7 ] Installing OpenClaw..."
npm install -g openclaw@latest 2>&1 | Out-Null
Write-Green " ✓ OpenClaw installed"

Write-Yellow "[ Step 4/7 ] Clearing old API key environment variables..."
[System.Environment]::SetEnvironmentVariable("GROQ_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("GROQ_API_KEY", $null, "Machine")
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", $null, "Machine")
[System.Environment]::SetEnvironmentVariable("GOOGLE_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("GOOGLE_API_KEY", $null, "Machine")
[System.Environment]::SetEnvironmentVariable("OPENROUTER_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("OPENROUTER_API_KEY", $null, "Machine")
Write-Green " ✓ Cleared"

Write-Yellow "[ Step 5/7 ] Choose your AI provider..."
Write-Host " 1) Groq - Free tier (console.groq.com)"
Write-Host " 2) OpenRouter - Free models (openrouter.ai)"
Write-Host " 3) Google - Free tier (aistudio.google.com)"
$choice = Read-Host " Enter 1, 2, or 3"
switch ($choice) {
"1" {
$apiKey = Read-Host " Paste your Groq API key"
$env:GROQ_API_KEY = $apiKey
npx openclaw config set env.GROQ_API_KEY $apiKey 2>&1 | Out-Null
npx openclaw config set agents.defaults.model "groq/llama-3.3-70b-versatile" 2>&1 | Out-Null
Write-Green " ✓ Groq configured"
}
"2" {
$apiKey = Read-Host " Paste your OpenRouter API key"
$env:OPENROUTER_API_KEY = $apiKey
npx openclaw config set env.OPENROUTER_API_KEY $apiKey 2>&1 | Out-Null
npx openclaw config set agents.defaults.model "openrouter/mistralai/mistral-7b-instruct:free" 2>&1 | Out-Null
Write-Green " ✓ OpenRouter configured"
}
"3" {
$apiKey = Read-Host " Paste your Google Gemini API key"
$env:GOOGLE_API_KEY = $apiKey
npx openclaw config set env.GOOGLE_API_KEY $apiKey 2>&1 | Out-Null
npx openclaw config set agents.defaults.model "google/gemini-2.0-flash" 2>&1 | Out-Null
Write-Green " ✓ Google Gemini configured"
}
}

Write-Yellow "[ Step 6/7 ] Starting Gateway (30-60 seconds)..."
Start-Process -FilePath "npx" -ArgumentList "openclaw gateway --allow-unconfigured" -WindowStyle Normal
Start-Sleep -Seconds 45
Write-Green " ✓ Gateway started!"

Write-Yellow "[ Step 7/7 ] Getting your token..."
Start-Sleep -Seconds 3
$config = Get-Content "$defaultDir.openclaw\openclaw.json" | ConvertFrom-Json
$token = $config.gateway.auth.token

Write-Cyan "=============================================="
Write-Green " 🎉 OpenClaw is ready!"
Write-Cyan "=============================================="
Write-Host ""
Write-Host " Run this in a NEW PowerShell window:"
Write-Cyan " npx openclaw tui --token $token"
Write-Host ""
Write-Yellow " ⚠ Don't spam test messages — fills token history fast!"
Write-Host ""
Read-Host "Press Enter to exit"

openclaw #windows #powershell #ai #tutorial

Copy everything above, paste into dev.to/new, add the challenge link at the bottom, and submit! 🏆You said: Openclaw installer post · this oneOpenclaw installer post · this one1:52 PMClaude responded: Here's the full content of the openclaw-installer-post to copy into DEV.Here's the full content of the openclaw-installer-post to copy into DEV.to:

I Built a Windows Auto-Installer for OpenClaw (So You Don't Suffer Like I Did)
Submitted for the DEV.to OpenClaw Challenge — OpenClaw in Action prompt

I spent 3 days getting OpenClaw running on Windows 11.
Three. Days.
Not because the tool is bad — but because Windows has some specific gotchas that nobody had documented yet. Old API keys hiding in environment variables. Device pairing errors. Token limit walls. Gateway crashes.
So I did what any frustrated developer does: I turned the pain into a tool.
Meet install-openclaw.ps1 — a one-click PowerShell installer that handles everything automatically.

🤔 What Problem Does It Solve?
Getting OpenClaw running on Windows involves:

Checking Node.js is installed
Choosing a safe install directory
Installing OpenClaw globally via npm
Clearing old API keys from Windows environment variables (the sneaky one)
Choosing and configuring an AI provider
Starting the gateway
Finding your auth token

My installer handles all of them automatically.

✨ Features

✅ Auto-detects Node.js
✅ Lets you choose your install drive
✅ Automatically clears old API key environment variables
✅ Supports Groq, OpenRouter, and Google Gemini
✅ Starts the gateway automatically
✅ Shows your token and exact commands to connect
✅ Warns you about common mistakes

🚀 How to Use It
Step 1 — Copy the script below and save it as install-openclaw.ps1
Step 2 — Right-click → Run with PowerShell
Step 3 — Follow the prompts and you're done!

If PowerShell blocks the script, run this first:
powershellSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

💡 The Sneakiest Windows Bug
Old API keys saved as Windows environment variables silently override your config file — even after you update it. This gave me HTTP 401: Invalid API Key for hours despite having the correct key in my config.
Check for it:
powershellecho $env:GROQ_API_KEY
Clear it permanently:
powershell[System.Environment]::SetEnvironmentVariable("GROQ_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("GROQ_API_KEY", $null, "Machine")
My installer does this automatically.

⚠️ Other Lessons Learned

Don't spam test messages while debugging — fills your token history fast, hitting Groq's 12k TPM limit
Use OpenRouter for most reliable free access — no strict TPM limits
Always keep the gateway window open — TUI depends on it

📥 The Full Script
powershell# OpenClaw Windows Auto-Installer

Created by Deep — based on 3 days of real troubleshooting

$ErrorActionPreference = "SilentlyContinue"

function Write-Green { param($msg) Write-Host $msg -ForegroundColor Green }
function Write-Yellow { param($msg) Write-Host $msg -ForegroundColor Yellow }
function Write-Red { param($msg) Write-Host $msg -ForegroundColor Red }
function Write-Cyan { param($msg) Write-Host $msg -ForegroundColor Cyan }

Clear-Host
Write-Cyan "=============================================="
Write-Cyan " 🦞 OpenClaw Windows Auto-Installer 🦞"
Write-Cyan " By Deep | DEV.to OpenClaw Challenge 2026"
Write-Cyan "=============================================="
Write-Host ""

Write-Yellow "[ Step 1/7 ] Checking Node.js..."
$node = Get-Command node -ErrorAction SilentlyContinue
if (-not $node) {
Write-Red " ✗ Node.js not found!"
Write-Host " Please install Node.js LTS from https://nodejs.org"
Read-Host " Press Enter to exit"
exit 1
}
Write-Green " ✓ Node.js found: $(node --version)"

Write-Yellow "[ Step 2/7 ] Choosing install directory..."
$defaultDir = "D:\OpenClaw"
if (-not (Test-Path "D:\")) { $defaultDir = "C:\OpenClaw" }
$userDir = Read-Host " Press Enter for $defaultDir or type a custom path"
if ($userDir -ne "") { $defaultDir = $userDir }
if (-not (Test-Path $defaultDir)) { New-Item -ItemType Directory -Path $defaultDir -Force | Out-Null }
Set-Location $defaultDir
Write-Green " ✓ Using: $defaultDir"

Write-Yellow "[ Step 3/7 ] Installing OpenClaw..."
npm install -g openclaw@latest 2>&1 | Out-Null
Write-Green " ✓ OpenClaw installed"

Write-Yellow "[ Step 4/7 ] Clearing old API key environment variables..."
[System.Environment]::SetEnvironmentVariable("GROQ_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("GROQ_API_KEY", $null, "Machine")
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", $null, "Machine")
[System.Environment]::SetEnvironmentVariable("GOOGLE_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("GOOGLE_API_KEY", $null, "Machine")
[System.Environment]::SetEnvironmentVariable("OPENROUTER_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("OPENROUTER_API_KEY", $null, "Machine")
Write-Green " ✓ Cleared"

Write-Yellow "[ Step 5/7 ] Choose your AI provider..."
Write-Host " 1) Groq - Free tier (console.groq.com)"
Write-Host " 2) OpenRouter - Free models (openrouter.ai)"
Write-Host " 3) Google - Free tier (aistudio.google.com)"
$choice = Read-Host " Enter 1, 2, or 3"
switch ($choice) {
"1" {
$apiKey = Read-Host " Paste your Groq API key"
$env:GROQ_API_KEY = $apiKey
npx openclaw config set env.GROQ_API_KEY $apiKey 2>&1 | Out-Null
npx openclaw config set agents.defaults.model "groq/llama-3.3-70b-versatile" 2>&1 | Out-Null
Write-Green " ✓ Groq configured"
}
"2" {
$apiKey = Read-Host " Paste your OpenRouter API key"
$env:OPENROUTER_API_KEY = $apiKey
npx openclaw config set env.OPENROUTER_API_KEY $apiKey 2>&1 | Out-Null
npx openclaw config set agents.defaults.model "openrouter/mistralai/mistral-7b-instruct:free" 2>&1 | Out-Null
Write-Green " ✓ OpenRouter configured"
}
"3" {
$apiKey = Read-Host " Paste your Google Gemini API key"
$env:GOOGLE_API_KEY = $apiKey
npx openclaw config set env.GOOGLE_API_KEY $apiKey 2>&1 | Out-Null
npx openclaw config set agents.defaults.model "google/gemini-2.0-flash" 2>&1 | Out-Null
Write-Green " ✓ Google Gemini configured"
}
}

Write-Yellow "[ Step 6/7 ] Starting Gateway (30-60 seconds)..."
Start-Process -FilePath "npx" -ArgumentList "openclaw gateway --allow-unconfigured" -WindowStyle Normal
Start-Sleep -Seconds 45
Write-Green " ✓ Gateway started!"

Write-Yellow "[ Step 7/7 ] Getting your token..."
Start-Sleep -Seconds 3
$config = Get-Content "$defaultDir.openclaw\openclaw.json" | ConvertFrom-Json
$token = $config.gateway.auth.token

Write-Cyan "=============================================="
Write-Green " 🎉 OpenClaw is ready!"
Write-Cyan "=============================================="
Write-Host ""
Write-Host " Run this in a NEW PowerShell window:"
Write-Cyan " npx openclaw tui --token $token"
Write-Host ""
Write-Yellow " ⚠ Don't spam test messages — fills token history fast!"
Write-Host ""
Read-Host "Press Enter to exit"

This project came from 3 days of real struggle. I hope it saves you the same pain! 🦞

Top comments (1)

Collapse
 
southy404 profile image
southy404

I wish I had seen this earlier 😂
the struggle is real…

I went through a very similar experience here:
dev.to/southy404/i-tried-openclaw-...