使用场景
6 个真实场景 — 看看怎么用 Gateway New 解决你的问题。
🏢
批量 IT 运维
场景
管几十上百台 Windows 工作站 / 服务器,每周要打补丁、装软件、改注册表
做法 一个脚本批量调 SDK,几十台机器同时操作;离线机自动跳过,结果汇总落 PG
关键 API exec_shell / exec_program / make_dir / file_writefor h in c.list_hosts():
if not h.online: continue
c.exec_shell(h.id, ShellRequest(
path="powershell.exe",
args="Install-Module -Name PSWindowsUpdate -Force",
timeout_s=300,
)) 🤖
CI / 自动化测试集群
场景
Jenkins / GitHub Actions 跑测试要拉 Windows 环境;每次新建 VM 太慢太贵
做法 几台常驻 Windows agent,CI 任务通过 SDK 实时占用:跑测试 → 拿结果 → 清环境
关键 API exec_shell (timeout) / file/stream (拉 artifact) / process/list// Go test 流水线
host := pickAvailable(client)
client.ExecShell(ctx, host.ID, sdk.ShellRequest{
Path: "msbuild.exe",
Args: "MyProject.sln /p:Configuration=Release",
TimeoutS: 1800,
}) 📦
文件分发 / 配置下发
场景
客户端机器要更新配置文件 / 推送补丁 / 部署小工具
做法 中枢 net/download 让 agent 自己从 CDN 拉,比经中枢转发省带宽;下完自动解 zip
关键 API net/download / zip/extract / file/copyc.raw_control(host_id, controls=256, path="",
data={"url": "https://cdn.example.com/patch-2026-05.zip",
"save_to": "C:/temp/patch.zip"})
c.raw_control(host_id, controls=128, path="C:/temp/patch.zip",
data={"extract_to": "C:/Program Files/MyApp"}) 📊
监控告警 + 自动响应
场景
Grafana 告警 → 需要自动重启服务 / 清磁盘 / 收集日志,不要 oncall 人工 SSH
做法 告警 webhook → 你的业务系统 → 调 Gateway API 拿 metrics 决策 → kill_process / 跑修复脚本
关键 API system_metrics (0.1 token) / exec_shell / kill_process / service/ctl# Grafana webhook → 你的 handler
m = c.system_metrics(host_id)
if m.disk_pct > 90:
c.exec_shell(host_id, ShellRequest(
path="cmd.exe",
args="/c del /Q C:\Windows\Temp\*",
)) 💬
客服 / 售后远程支援
场景
客户 PC 出问题,客服要远程跑诊断命令、看日志、改注册表,但不能装 TeamViewer
做法 客户机预装 agent;客服系统集成 SDK + 一个内嵌终端 (xterm.js) 直连主机 ConPTY
关键 API /terminal/ticket + /terminal/ws (持久 PowerShell 会话)// 客服系统前端(React + xterm.js)
const r = await fetch('/api/customer-support/terminal/' + customerHostId);
const { ws_url } = await r.json();
const ws = new WebSocket(ws_url);
// xterm.onData → ws.send;ws.onmessage → term.write 🔌
嵌入 SaaS 做自有 RMM
场景
你自己已经有客户管理 / 工单 / 计费系统,只想把「远程操控 Windows 机器」作为一个能力嵌入
做法 Client API 一行注册新主机 + 一行下 ps1 安装包;客户在你的平台双击装,从此 Gateway 当你的「远程能力层」
关键 API /hosts (POST/DELETE/install-token/installer)、L1 配置 (PUT /hosts/:id/l1-config) — 详见 docs/host-management# 你的业务系统:客户注册 → 自动建主机 + 发安装包
host_id = gw.hosts.create(name=customer.name).host.id
ps1 = gw.hosts.installer(host_id, format="ps1")
email.send(customer.email, attach=ps1)
# 客户机装好后,业务买"清理大师"
yourBilling.deduct(customer, "1.99 USD")
gw.exec_shell(host_id, ShellRequest(
path="powershell.exe",
args="-File C:/MyTools/cleanup.ps1",
timeout_s=600,
)) 开始使用
上面 6 个场景都跑得通。注册立送体验 token,5 分钟接入 SDK。