Skip to content

[Windows] Node.js installer path not escaped in PowerShell command causes silent install failure #72

@JasonYang318

Description

@JasonYang318

問題描述

installNodeWithAdmin() 中,installerPath 直接以字串插值方式嵌入 PowerShell 命令:

檔案electron/main/cli.ts 第 1831 行

```typescript
Start-Process -FilePath msiexec -ArgumentList '/i','${installerPath}','/qn' -Verb RunAs -Wait
```

installerPath 含有空格(例如用戶名為 John Doe,路徑為 C:\Users\John Doe\AppData\...),PowerShell 會將路徑拆成多個參數,導致 msiexec 解析失敗,安裝無聲結束。

影響範圍

  • Windows 用戶名含空格的帳號(如 John Doe王 小明 等)
  • 臨時目錄路徑含空格的系統環境
  • 表現為安裝流程無錯誤但 Node.js 未實際安裝

重現條件

  1. 使用 Windows 且用戶名含空格
  2. 透過 Qclaw 執行 Node.js 安裝
  3. 安裝結束但 Node.js 未正確安裝

建議修法

改用 PowerShell 陣列參數形式傳遞路徑,避免字串插值:

```powershell
Start-Process -FilePath msiexec -ArgumentList @('/i', 'C:\path with spaces\node.msi', '/qn') -Verb RunAs -Wait
```

或在 TypeScript 中對路徑做適當的 escape 處理後再插入字串。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions