Files
wehub-resource-sync bb087aad19
CI / format (push) Failing after 2s
CI / packaging (push) Failing after 0s
CI / test (push) Failing after 3s
chore: import upstream snapshot with attribution
2026-07-13 11:58:56 +08:00

22 lines
533 B
Dart

import 'dart:io';
import 'package:logging/logging.dart';
final _logger = Logger('CmdHelper');
/// Runs [commands] in cmd having admin privileges.
Future<void> runWindowsCommandAsAdmin(List<String> commands) async {
try {
final joinedCommands = commands.join(' & ');
await Process.run(
'powershell',
[
'-Command',
"Start-Process -Verb RunAs cmd.exe -Args '/c', '$joinedCommands & echo. & pause'",
],
);
} catch (e) {
_logger.warning('Could not run command as admin', e);
}
}