update call poweshell

This commit is contained in:
leedongmyung 2025-01-05 11:46:23 +09:00
parent 9777afe02d
commit 8ffb07a58c

View file

@ -134,14 +134,17 @@ class ProcessExecutor {
if (result.exitCode == 0) {
var path = result.stdout.toString().split('\n')[0];
_powershellPath = File(path).absolute.path;
print(_powershellPath);
}
if (_powershellPath.isEmpty) {
throw UnsupportedError('Not found powershell');
}
result = await Process.run(
_powershellPath,
'cmd',
[
'/C',
'powershell',
'-Command',
'Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned'
],
@ -234,9 +237,11 @@ class ProcessExecutor {
file.createSync();
file.writeAsStringSync(shell.toString(), flush: true);
var powershell = await getPowershell();
print(powershell);
try {
processData.process = await Process.start(await getPowershell(),
['-NoProfile', '-File', file.absolute.path]);
processData.process = await Process.start('cmd',
['/C', 'powershell', '-NoProfile', '-File', file.absolute.path]);
} on Exception catch (e) {
logHandler ?? (e, LogType.error);
}
@ -294,11 +299,11 @@ class ProcessExecutor {
print(file.absolute.path);
await getPowershell();
var powshell = await getPowershell();
processResult = await Process.run(
await getPowershell(), // PowerShell
['-NoProfile', '-File', file.absolute.path],
'cmd', // PowerShell
['/C', 'powershell', '-NoProfile', '-File', file.absolute.path],
runInShell: true);
file.deleteSync();