Support spaces in path name for elevate.

- Also log stderr on failure to elevate.
This commit is contained in:
Dain Nilsson 2022-03-31 14:50:42 +02:00
parent cabdc9effd
commit 70404d2029
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8

View File

@ -138,12 +138,19 @@ class RpcSession {
// Launch the elevated process
final process =
await Process.start('powershell.exe', ['-NoProfile', '-Command', '-']);
_log.info('Attempting to elevate $executable');
process.stdin.writeln(
'Start-Process $executable -Verb runAs -WindowStyle hidden -ArgumentList "--tcp $port $nonce"');
'Start-Process "$executable" -Verb runAs -WindowStyle hidden -ArgumentList "--tcp $port $nonce"');
await process.stdin.flush();
await process.stdin.close();
if (await process.exitCode != 0) {
await server.close();
final error = await process.stderr
.transform(const Utf8Decoder())
.transform(const LineSplitter())
.join('\n');
_log.warning('Failed to elevate RPC process', error);
return false;
}
_log.config('Elevated RPC process started');