問題描述
在 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 未實際安裝
重現條件
- 使用 Windows 且用戶名含空格
- 透過 Qclaw 執行 Node.js 安裝
- 安裝結束但 Node.js 未正確安裝
建議修法
改用 PowerShell 陣列參數形式傳遞路徑,避免字串插值:
```powershell
Start-Process -FilePath msiexec -ArgumentList @('/i', 'C:\path with spaces\node.msi', '/qn') -Verb RunAs -Wait
```
或在 TypeScript 中對路徑做適當的 escape 處理後再插入字串。
問題描述
在
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 解析失敗,安裝無聲結束。影響範圍
John Doe、王 小明等)重現條件
建議修法
改用 PowerShell 陣列參數形式傳遞路徑,避免字串插值:
```powershell
Start-Process -FilePath msiexec -ArgumentList @('/i', 'C:\path with spaces\node.msi', '/qn') -Verb RunAs -Wait
```
或在 TypeScript 中對路徑做適當的 escape 處理後再插入字串。