diff --git a/lib/host.js b/lib/host.js
index 7d2aa6b..b6c249a 100644
--- a/lib/host.js
+++ b/lib/host.js
@@ -613,22 +613,16 @@ export function apply(ctx, config) {
}
async function spawnShell() {
- const cmd = shellPath()
- if (!fs.existsSync(cmd)) return { ok: false, error: `launcher not found: ${cmd}` }
- try {
- const shell = ctx.get('shell')
- const sp = ctx.get('sandboxPolicy')
- const policy = sp?.resolve?.({ mode: 'danger-full-access' })
- if (shell?.resolve && shell?.run) {
- const spec = shell.resolve({ command: `cmd /c start "" "${cmd}"`, ...(policy ? { sandboxPolicy: policy } : {}) })
- await shell.run(spec)
- return { ok: true, via: 'ctx.shell' }
- }
- } catch (e) { log('ctx.shell launch failed, fallback to spawn:', String(e?.message || e)) }
+ // 直接起 powershell(隐藏窗口)。**不要**走 `cmd /c start`:那会弹出一个黑色控制台窗口
+ // (用户已经看到过:标题 C:\WINDOWS\system32\cmd.exe,且批处理里的中文被 GBK 解析成乱码报错)。
+ const ps1 = path.join(REPO, 'shell', 'float-window.ps1')
+ if (!fs.existsSync(ps1)) return { ok: false, error: `shell script not found: ${ps1}` }
try {
const { spawn } = await import('node:child_process')
- spawn('cmd', ['/c', 'start', '', cmd], { detached: true, stdio: 'ignore', windowsHide: true }).unref()
- return { ok: true, via: 'spawn' }
+ spawn('powershell.exe',
+ ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-WindowStyle', 'Hidden', '-File', ps1],
+ { detached: true, stdio: 'ignore', windowsHide: true }).unref()
+ return { ok: true, via: 'spawn powershell (hidden)' }
} catch (e) { return { ok: false, error: String(e?.message || e) } }
}
diff --git a/shell/ui.html b/shell/ui.html
index 96b9027..2dfcec8 100644
--- a/shell/ui.html
+++ b/shell/ui.html
@@ -568,10 +568,16 @@
+