@aiyiran/myclaw 1.0.16 → 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.
- package/package.json +1 -1
- package/wsl2.js +9 -5
package/package.json
CHANGED
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
|
-
|
|
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);
|