@aiyiran/myclaw 1.0.17 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/wsl2.js +9 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
package/wsl2.js CHANGED
@@ -50,13 +50,17 @@ function launchElevatedPS(script) {
50
50
  : path.join(os.tmpdir(), 'myclaw');
51
51
  try { fs.mkdirSync(tmpDir, { recursive: true }); } catch {}
52
52
  const scriptPath = path.join(tmpDir, 'wsl2_installer.ps1');
53
- fs.writeFileSync(scriptPath, script, 'utf8');
53
+
54
+ // UTF-8 with BOM — PowerShell 需要 BOM 才能正确读取中文
55
+ const BOM = '\uFEFF';
56
+ fs.writeFileSync(scriptPath, BOM + script, 'utf8');
57
+
58
+ // 用 -NoExit 确保即使脚本出错窗口也不会关闭
59
+ const escaped = scriptPath.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
60
+ const cmd = `powershell -Command "Start-Process powershell -ArgumentList @('-NoProfile','-ExecutionPolicy','Bypass','-NoExit','-File','${escaped}') -Verb RunAs"`;
54
61
 
55
62
  try {
56
- execSync(
57
- `powershell -Command "Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File \\"${scriptPath}\\"' -Verb RunAs"`,
58
- { stdio: 'inherit' }
59
- );
63
+ execSync(cmd, { stdio: 'inherit' });
60
64
  return true;
61
65
  } catch (err) {
62
66
  console.error('[' + C.r + '错误' + C.nc + '] 无法获取管理员权限: ' + err.message);