尚未安裝 OpenClaw?點此查看一鍵安裝指令
curl -fsSL https://openclaw.ai/install.sh | bashiwr -useb https://openclaw.ai/install.ps1 | iexcurl -fsSL https://openclaw.ai/install.cmd -o install.cmd && install.cmd && del install.cmd- CMD 腳本本質是 PowerShell 的 wrapper——
install.cmd(102 行)下載install.ps1至%TEMP%,再以powershell -ExecutionPolicy Bypass執行,繞過企業環境中常見的 PowerShell 執行策略限制 - Onboard 2026.2.25 新增 QuickStart 模式——一鍵設定 Gateway port 18789、Loopback 綁定、Token Auth 預設啟用,省去舊版逐項手動配置的步驟
- Qwen OAuth 免費模型整合——透過 Device Code Flow(
chat.qwen.ai/authorize)完成授權,無需手動貼 API Key,Token 自動刷新 - Gateway 服務安裝需管理員權限(底層依賴
schtasks)——非管理員環境可用前台模式openclaw gateway替代,Gateway 正常監聽後 Dashboard 與 Telegram 即可連線
一、為什麼選擇 CMD 安裝
OpenClaw 在 Windows 上提供三條安裝路徑:PowerShell 一行指令(iwr | iex)、CMD 腳本、以及 WSL2 環境下的 Shell 安裝。我們先前已記錄了 PowerShell 安裝路徑與 WSL2 部署指南。本文聚焦第二條路徑——CMD 腳本安裝。
選擇 CMD 安裝的三個實際場景:
- PowerShell 執行策略受限:許多企業環境透過群組原則(Group Policy)將 PowerShell 的 ExecutionPolicy 設為
Restricted或AllSigned,禁止執行未簽署的腳本。install.cmd透過-ExecutionPolicy Bypass參數繞過此限制,是最直接的解法 - 非 PowerShell 終端環境:在 Git Bash、MSYS2、ConEmu 等第三方終端中,CMD 腳本比 PowerShell 指令更容易直接執行
- CI/CD 管線需求:部分 Windows CI runner(如 Jenkins agent)預設使用 CMD 而非 PowerShell,
install.cmd可直接嵌入建置腳本
install.cmd 的內部運作
官方 install.cmd 共 102 行,本質上是一個精簡的 PowerShell wrapper[1]。其核心邏輯可拆解為四個階段:
- 參數解析:支援
--git、--npm(預設)、--tag <ver>、--no-onboard、--no-git-update、--dry-run - 前置檢查:驗證
curl與powershell是否可用 - 下載 install.ps1:從
https://openclaw.ai/install.ps1下載至%TEMP%\openclaw-install.ps1 - 委派執行:以
powershell -NoProfile -ExecutionPolicy Bypass -File "%TMP%" %PS_ARGS%執行,完成後自動刪除暫存檔
關鍵設計選擇:-ExecutionPolicy Bypass 確保即使系統 ExecutionPolicy 為 Restricted,安裝腳本仍可執行。這也是 CMD 安裝路徑相較於直接在 PowerShell 中執行 iwr | iex 的核心優勢——後者在嚴格策略下會被阻擋。
二、安裝流程
2.1 一行指令安裝
開啟 CMD 或任何支援 CMD 指令的終端,執行[1]:
curl -fsSL https://openclaw.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
這行指令的三個步驟:下載 install.cmd → 執行安裝 → 刪除安裝腳本。我們在實測中先以 --no-onboard 參數執行,將 onboard 步驟分開記錄:
D:\Projects> install.cmd --no-onboard
OpenClaw Installer
[OK] Windows detected
[OK] Node.js v24.13.1 found
[*] Installing OpenClaw (openclaw@latest)...
[OK] OpenClaw installed
OpenClaw installed successfully (2026.2.25)!
Home sweet home. Don't worry, I won't rearrange the furniture.
Skipping onboard (requested). Run openclaw onboard later.
安裝程式自動偵測到系統已安裝 Node.js v24.13.1,跳過 Node.js 安裝步驟,直接透過 npm install -g openclaw@latest 全域安裝。整個過程約 30 秒。
2.2 install.cmd 腳本參數一覽
| 參數 | 說明 | 預設值 |
|---|---|---|
--npm | 透過 npm 安裝(預設) | 是 |
--git | 從 git checkout 安裝 | 否 |
--tag <ver> | 指定安裝版本 | latest |
--no-onboard | 跳過 onboarding | 否 |
--no-git-update | 跳過 git pull(git 安裝時) | 否 |
--dry-run | 顯示將執行的動作,不實際安裝 | 否 |
2.3 安裝後 Doctor 診斷報告
安裝完成後執行 openclaw doctor 確認系統狀態:
C:\Users\HYC> openclaw doctor
┌ OpenClaw doctor
│
◇ Gateway ─────────────────────────────────────────────
│ gateway.mode is unset; gateway start will be blocked.
│ Fix: run openclaw configure and set Gateway mode.
│ Missing config: run openclaw setup first.
├───────────────────────────────────────────────────────
◇ Gateway auth ────────────────────────────────────────
│ Gateway auth is off or missing a token. Token auth
│ is now the recommended default (including loopback).
├───────────────────────────────────────────────────────
◇ State integrity ────────────────────────────────────────────
│ - OAuth dir not present (~\.openclaw\credentials).
│ - CRITICAL: Session store dir missing
│ (~\.openclaw\agents\main\sessions).
├──────────────────────────────────────────────────────────────
◇ Skills status ──────────
│ Eligible: 9
│ Missing requirements: 43
│ Blocked by allowlist: 0
├──────────────────────────
◇ Plugins ────────
│ Loaded: 4
│ Disabled: 32
│ Errors: 0
├──────────────────
◇ Gateway ─────────────────
│ Gateway not running.
│ Gateway service not installed.
├───────────────────────────
◇ Memory search ──────────────────────────────────────────
│ Memory search is enabled but no embedding provider
│ is configured. Semantic recall will not work.
├──────────────────────────────────────────────────────────
└ Doctor complete.
這是全新安裝的典型狀態:Gateway 尚未設定、服務未註冊、OAuth 與 Session 目錄未建立。接下來的 openclaw onboard 會逐一處理這些項目。
三、Onboard 互動設定全記錄
OpenClaw 2026.2.25 版的 onboard 精靈相較於先前版本有顯著變化。以下逐步記錄完整的互動流程。
3.1 安全性聲明與確認
Onboard 開始時顯示安全性警告[4]:
C:\Users\HYC> openclaw onboard
🦞 OpenClaw 2026.2.25 (4b5d4a4)
┌ OpenClaw onboarding
│
◇ Security ──────────────────────────────────────────────
│ Security warning — please read.
│
│ OpenClaw is a hobby project and still in beta.
│ By default, OpenClaw is a personal agent: one trusted
│ operator boundary.
│ This bot can read files and run actions if tools
│ are enabled.
│
│ Recommended baseline:
│ - Pairing/allowlists + mention gating.
│ - Multi-user/shared inbox: split trust boundaries.
│ - Sandbox + least-privilege tools.
│ - Keep secrets out of the agent's reachable filesystem.
│
│ Must read: https://docs.openclaw.ai/gateway/security
├─────────────────────────────────────────────────────────
│
◇ Continue? Yes
這段安全性聲明是 2026.2.25 版的顯著改進——明確告知使用者 OpenClaw 預設為「單一信任操作者邊界」(single trusted operator boundary),並提供具體的安全強化建議。
3.2 QuickStart 模式
確認安全聲明後,精靈詢問 onboarding 模式。QuickStart 是 2026.2.25 版新增的模式,一鍵完成 Gateway 基礎設定:
◇ Onboarding mode
│ QuickStart
│
◇ QuickStart ─────────────────────────╮
│ │
│ Gateway port: 18789 │
│ Gateway bind: Loopback (127.0.0.1) │
│ Gateway auth: Token (default) │
│ Tailscale exposure: Off │
│ Direct to chat channels. │
│ │
├──────────────────────────────────────╯
QuickStart 自動配置了四項關鍵設定:
- Port 18789:OpenClaw Gateway 的預設 WebSocket 埠號
- Loopback 綁定:僅監聽 127.0.0.1,外部網路無法直接存取
- Token Auth:Gateway 連線需要 Token 驗證,即使是本機 loopback 也不例外——這是舊版中需手動啟用的安全功能,現已成為預設
- Tailscale 關閉:不透過 Tailscale VPN 暴露 Gateway
3.3 Qwen OAuth 授權流程
選擇 Qwen 作為模型供應商後,精靈啟動 Device Code Flow 授權[10]:
◇ Model/auth provider
│ Qwen
│
◓ Starting Qwen OAuth…
│
◇ Qwen OAuth ──────────────────────────────────────────────
│ Open https://chat.qwen.ai/authorize?user_code=-DPGH765
│ &client=qwen-code to approve access.
│ If prompted, enter the code -DPGH765.
├───────────────────────────────────────────────────────────
◇ Qwen OAuth complete
│
◇ Model configured ─────────────────────────────╮
│ Default model set to qwen-portal/coder-model │
├────────────────────────────────────────────────╯
│
◇ Provider notes ─────────────────────────────────────────
│ Qwen OAuth tokens auto-refresh. Re-run login if
│ refresh fails or access is revoked.
│ Base URL defaults to https://portal.qwen.ai/v1.
├──────────────────────────────────────────────────────────
Device Code Flow 的操作方式:精靈顯示一個授權 URL 與驗證碼,使用者在瀏覽器中開啟該 URL、登入 Qwen 帳號、輸入驗證碼即完成授權。完全不需要手動複製 API Key——Token 自動寫入設定檔,且支援自動刷新。這是 OpenClaw 整合免費 AI 模型最無痛的方式。
3.4 Telegram Bot Token 設定
精靈顯示所有可用的通訊渠道(Telegram、WhatsApp、Discord、Slack、Signal 等 23 個渠道),我們選擇 Telegram[5]:
◇ Select channel (QuickStart)
│ Telegram (Bot API)
│
◇ Telegram bot token ──────────────────────────────────
│ 1) Open Telegram and chat with @BotFather
│ 2) Run /newbot (or /mybots)
│ 3) Copy the token (looks like 123456:ABC...)
│ Docs: https://docs.openclaw.ai/telegram
├───────────────────────────────────────────────────────
│
◇ Enter Telegram bot token
│ <YOUR_BOT_TOKEN>
輸入從 @BotFather 取得的 Bot Token[11],精靈自動寫入 %USERPROFILE%\.openclaw\openclaw.json 並啟用 Telegram 外掛。
Updated ~\.openclaw\openclaw.json
Workspace OK: ~\.openclaw\workspace
Sessions OK: ~\.openclaw\agents\main\sessions
3.5 Skills 偵測與安裝
精靈偵測到可安裝的 Skills 並嘗試安裝缺失的相依套件[6]:
◇ Skills status ─────────────╮
│ Eligible: 9 │
│ Missing requirements: 35 │
│ Unsupported on this OS: 8 │
│ Blocked by allowlist: 0 │
├─────────────────────────────╯
│
◇ Install missing skill dependencies
│ 🎮 gog, 🎙️ openai-whisper, 🗣️ sag
│
◇ Install failed: gog — brew not installed
◇ Install failed: sag — brew not installed
◇ Install failed: openai-whisper — brew not installed
三個 Skills(gog、openai-whisper、sag)安裝失敗,原因是它們的套件管理依賴 Homebrew,而 Homebrew 在 Windows 原生環境中不可用。這是 Windows 原生安裝的已知限制——這些 Skills 需要 WSL2 或 macOS/Linux 環境。
精靈接著詢問各 Skill 需要的 API Key(Gemini、Notion、OpenAI、ElevenLabs),我們逐一設定。
3.6 Hooks 設定
Hooks 是 OpenClaw 的自動化機制——在特定事件觸發時執行預定義的動作[7]:
◇ Hooks ──────────────────────────────────────────────────
│ Hooks let you automate actions when agent commands
│ are issued.
│ Example: Save session context to memory when you
│ issue /new or /reset.
│ Learn more: https://docs.openclaw.ai/automation/hooks
├──────────────────────────────────────────────────────────
│
◇ Enable hooks?
│ 📝 command-logger, 💾 session-memory
│
◇ Hooks Configured ────────────────────────────────
│ Enabled 2 hooks: session-memory, command-logger │
├───────────────────────────────────────────────────╯
我們啟用了兩個 Hooks:
- session-memory:在執行
/new或/reset指令時,自動將當前 Session 上下文儲存至 Memory - command-logger:記錄所有透過渠道發出的指令,方便事後審計
3.7 Gateway 服務安裝(非管理員失敗)
這是 onboard 流程中唯一的失敗點。精靈嘗試將 Gateway 註冊為 Windows 服務:
◇ Gateway service runtime ────────────────────────────────
│ QuickStart uses Node for the Gateway service
│ (stable + supported).
├──────────────────────────────────────────────────────────
│
◇ Gateway service install failed.
│
◇ Gateway ───────────────────────────────────────────────────
│ Run PowerShell as Administrator or rerun without
│ installing the daemon.
├─────────────────────────────────────────────────────────────
│
◇ Gateway ────────────────────────────────────────────────────
│ Tip: rerun from an elevated PowerShell (Start → type
│ PowerShell → right-click → Run as administrator) or
│ skip service install.
├──────────────────────────────────────────────────────────────
Gateway 服務安裝底層依賴 Windows 的 schtasks 工具[3],而 schtasks /Create 需要系統管理員權限。我們的 CMD 並非以管理員身份執行,因此安裝被拒絕。
解決方案:不安裝服務,改用前台模式。在另一個終端視窗中執行 openclaw gateway 即可啟動 Gateway:
C:\Users\HYC> openclaw gateway
🦞 OpenClaw 2026.2.25 (4b5d4a4)
23:26:11 [canvas] host mounted at http://127.0.0.1:18789/__openclaw__/canvas/
23:26:11 [heartbeat] started
23:26:11 [health-monitor] started (interval: 300s, grace: 60s)
23:26:11 [gateway] agent model: qwen-portal/coder-model
23:26:11 [gateway] listening on ws://127.0.0.1:18789, ws://[::1]:18789 (PID 17284)
23:26:11 [gateway] log file: \tmp\openclaw\openclaw-2026-02-27.log
23:26:11 [browser/server] Browser control listening on http://127.0.0.1:18791/ (auth=token)
23:26:12 [hooks:loader] Registered hook: boot-md -> gateway:startup
23:26:12 [hooks:loader] Registered hook: bootstrap-extra-files -> agent:bootstrap
23:26:12 [hooks:loader] Registered hook: command-logger -> command
23:26:12 [hooks:loader] Registered hook: session-memory -> command:new, command:reset
23:26:12 [hooks] loaded 4 internal hook handlers
23:26:14 [telegram] [default] starting provider (@openclaw4_1989_bot)
23:26:16 [gateway] device pairing auto-approved
23:26:16 [ws] webchat connected
Gateway 成功啟動,監聽在 ws://127.0.0.1:18789,Telegram provider 啟動,Dashboard WebSocket 連線成功。前台模式的唯一限制是關閉終端視窗即停止服務——對於測試與功能驗證而言完全夠用。需要持久化請參考PowerShell 安裝文章中的三條 Gateway 啟動路徑。
3.8 Telegram Pairing 配對
Gateway 啟動後,在 Telegram 中向你的 Bot 發送任何訊息,Bot 會回覆 pairing 配對資訊:
OpenClaw: access not configured.
Your Telegram user id: 1186367637
Pairing code: WR8XRQQA
Ask the bot owner to approve with:
openclaw pairing approve telegram WR8XRQQA
在另一個終端視窗中執行核准指令:
C:\Users\HYC> openclaw pairing approve telegram WR8XRQQA
Approved telegram sender 1186367637.
配對完成後,你的 Telegram 帳號即可與 OpenClaw Bot 正常對話。Pairing 機制是 OpenClaw 的預設安全策略——未經核准的 Telegram 用戶無法與 Bot 互動,防止未授權存取[4]。
3.9 Health Check 與 Dashboard
Gateway 啟動前,onboard 的 Health Check 會失敗(因為 Gateway 尚未運行):
Health check failed: gateway closed (1006 abnormal closure
(no close frame)): no close reason
Gateway target: ws://127.0.0.1:18789
Source: local loopback
手動啟動 openclaw gateway 後,Dashboard 即可正常連線:
◇ Dashboard ready ──────────────────────────────────────────────
│ Dashboard link (with token):
│ http://127.0.0.1:18789/#token=c64c519ab77de4e0c14584ea...
│ Opened in your browser.
├────────────────────────────────────────────────────────────────
四、CMD vs PowerShell vs WSL2 安裝方式對照表
三種 Windows 上的安裝路徑各有適用場景[8]:
| 維度 | CMD 腳本 | PowerShell | WSL2 |
|---|---|---|---|
| 安裝指令 | install.cmd | iwr | iex | curl | bash |
| 底層機制 | CMD → PowerShell wrapper | 直接 PowerShell | 原生 Shell |
| ExecutionPolicy 受限時 | 可用(自帶 Bypass) | 需手動 Bypass | 不受影響 |
| Gateway 持久化 | schtasks(需管理員) | schtasks(需管理員) | systemd(無需 root) |
| Skills 相容性 | 部分 Unix 工具不可用 | 部分 Unix 工具不可用 | 完整 Linux 工具鏈 |
| Homebrew | 不可用 | 不可用 | 可安裝 |
| 適用場景 | 企業受限環境、CI/CD | 一般 Windows 用戶 | 長期部署、完整功能 |
結論:CMD 與 PowerShell 安裝的最終結果完全相同(都是 npm install -g openclaw@latest),差異僅在於 CMD 腳本提供了繞過 ExecutionPolicy 的能力。如果你的環境沒有 PowerShell 限制,兩者擇一即可。若需要完整的 Skills 支援與 Homebrew 生態,WSL2 仍是最佳選擇。
五、Onboard 後 Doctor 報告解讀
完成 onboard 後再次執行 openclaw doctor,對比安裝後初始狀態的變化:
C:\Users\HYC> openclaw doctor
┌ OpenClaw doctor
│
◇ State integrity ────────────────────────────────────────
│ - CRITICAL: OAuth dir missing
│ (~\.openclaw\credentials).
├──────────────────────────────────────────────────────────
◇ Skills status ──────────
│ Eligible: 13
│ Missing requirements: 39
│ Blocked by allowlist: 0
├──────────────────────────
◇ Plugins ────────
│ Loaded: 6
│ Disabled: 30
│ Errors: 0
├──────────────────
◇ Gateway ─────────────────
│ Gateway not running.
├───────────────────────────
◇ Gateway connection ──────────────────────────
│ Gateway target: ws://127.0.0.1:18789
│ Source: local loopback
│ Config: C:\Users\HYC\.openclaw\openclaw.json
│ Bind: loopback
├───────────────────────────────────────────────
◇ Memory search ──────────────────────────────────────────
│ Memory search is enabled but no embedding provider
│ is configured.
├──────────────────────────────────────────────────────────
◇ Gateway ──────────────────────
│ Gateway service not installed.
├────────────────────────────────
└ Doctor complete.
Onboard 前後對比:
| 項目 | Onboard 前 | Onboard 後 | 變化 |
|---|---|---|---|
| Eligible Skills | 9 | 13 | +4(API Key 設定啟用) |
| Missing Requirements | 43 | 39 | -4 |
| Loaded Plugins | 4 | 6 | +2(Telegram + Hooks) |
| Disabled Plugins | 32 | 30 | -2 |
| Gateway mode | unset | local | 已設定 |
| Gateway auth | off | Token | 已啟用 |
| Session store | missing | OK | 已建立 |
仍存在的項目:
- OAuth dir missing(CRITICAL):OAuth 憑證目錄未建立。由於我們使用 Qwen OAuth 而非 WhatsApp pairing,此項不影響核心功能。執行
openclaw doctor --fix可自動建立 - Gateway not running / not installed:前台模式下 Gateway 需手動啟動,不會被 doctor 偵測為「installed」。這是預期行為
- Memory search 無 embedding provider:語義搜尋需要額外的 embedding API Key。可設定
OPENAI_API_KEY、GEMINI_API_KEY等環境變數來啟用[9]
結語
CMD 安裝路徑填補了 OpenClaw 在 Windows 上的最後一塊拼圖。對於 PowerShell 執行策略受限的企業環境,install.cmd 提供了零阻力的安裝體驗。而 2026.2.25 版的 onboard 精靈——特別是 QuickStart 模式與 Qwen OAuth 整合——大幅降低了首次設定的複雜度。
三條 Windows 安裝路徑現已完整記錄:PowerShell 版、本文的 CMD 版、以及 WSL2 部署指南。若需移除 OpenClaw,請參考 Windows 完全移除實戰。



