fix: UWPTool no privileges

This commit is contained in:
Memory 2025-08-29 20:06:43 +08:00 committed by GitHub
parent 6d21f904b3
commit 7743097b51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,8 +34,20 @@ export function openFile(type: 'profile' | 'override', id: string, ext?: 'yaml'
}
export async function openUWPTool(): Promise<void> {
const execPromise = promisify(exec)
const execFilePromise = promisify(execFile)
const uwpToolPath = path.join(resourcesDir(), 'files', 'enableLoopback.exe')
const { checkAdminPrivileges } = await import('../core/manager')
const isAdmin = await checkAdminPrivileges()
if (!isAdmin) {
const escapedPath = uwpToolPath.replace(/'/g, "''")
const command = `powershell -Command "Start-Process -FilePath '${escapedPath}' -Verb RunAs -Wait"`
await execPromise(command, { windowsHide: true })
return
}
await execFilePromise(uwpToolPath)
}