From 6bdb133ceaf5e619f496a1dc8f5d691b036f2622 Mon Sep 17 00:00:00 2001 From: Memory <134070804+Memory2314@users.noreply.github.com> Date: Tue, 12 Aug 2025 21:56:58 +0800 Subject: [PATCH] fix: no admin rights on Windows (#933) --- src/main/sys/autoRun.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/sys/autoRun.ts b/src/main/sys/autoRun.ts index c0edb6e..4758641 100644 --- a/src/main/sys/autoRun.ts +++ b/src/main/sys/autoRun.ts @@ -84,7 +84,7 @@ export async function enableAutoRun(): Promise { const taskFilePath = path.join(tmpdir(), `${appName}.xml`) await writeFile(taskFilePath, Buffer.from(`\ufeff${getTaskXml()}`, 'utf-16le')) await execPromise( - `%SystemRoot%\\System32\\schtasks.exe /create /tn "${appName}" /xml "${taskFilePath}" /f` + `powershell Start-Process schtasks -Verb RunAs -ArgumentList '/create', '/tn', '${appName}', '/xml', '${taskFilePath}', '/f'` ) } if (process.platform === 'darwin') { @@ -121,7 +121,7 @@ Categories=Utility; export async function disableAutoRun(): Promise { if (process.platform === 'win32') { const execPromise = promisify(exec) - await execPromise(`%SystemRoot%\\System32\\schtasks.exe /delete /tn "${appName}" /f`) + await execPromise(`powershell Start-Process schtasks -Verb RunAs -ArgumentList '/delete', '/tn', '${appName}', '/f'`) } if (process.platform === 'darwin') { const execPromise = promisify(exec)