mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 13:10:30 +08:00
fix: UWPTool no privileges
This commit is contained in:
parent
6d21f904b3
commit
7743097b51
@ -34,8 +34,20 @@ export function openFile(type: 'profile' | 'override', id: string, ext?: 'yaml'
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function openUWPTool(): Promise<void> {
|
export async function openUWPTool(): Promise<void> {
|
||||||
|
const execPromise = promisify(exec)
|
||||||
const execFilePromise = promisify(execFile)
|
const execFilePromise = promisify(execFile)
|
||||||
const uwpToolPath = path.join(resourcesDir(), 'files', 'enableLoopback.exe')
|
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)
|
await execFilePromise(uwpToolPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user