From d0cdcd438d38498bf2caa46eb2096bdb1b75e372 Mon Sep 17 00:00:00 2001 From: leedongmyung Date: Sun, 5 Jan 2025 17:51:15 +0900 Subject: [PATCH] update exe powershell --- lib/platform/process.dart | 12 +++++------- lib/utils/os_startup.dart | 8 +++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/platform/process.dart b/lib/platform/process.dart index 3b1499c..e69216a 100644 --- a/lib/platform/process.dart +++ b/lib/platform/process.dart @@ -131,10 +131,8 @@ class ProcessExecutor { static Future initPowershell() async { if (!_initedPowershell) { var result = await Process.run( - 'cmd', + 'powershell', [ - '/C', - 'powershell', '-Command', 'Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned' ], @@ -231,8 +229,8 @@ class ProcessExecutor { await initPowershell(); try { - processData.process = await Process.start('cmd', - ['/C', 'powershell', '-NoProfile', '-File', file.absolute.path]); + processData.process = await Process.start( + 'powershell', ['-NoProfile', '-File', file.absolute.path]); } on Exception catch (e) { logHandler ?? (e, LogType.error); } @@ -293,8 +291,8 @@ class ProcessExecutor { await initPowershell(); processResult = await Process.run( - 'cmd', // PowerShell 실행 - ['/C', 'powershell', '-NoProfile', '-File', file.absolute.path], + 'powershell', // PowerShell 실행 + ['-NoProfile', '-File', file.absolute.path], runInShell: true); file.deleteSync(); diff --git a/lib/utils/os_startup.dart b/lib/utils/os_startup.dart index 2b62891..d97931f 100644 --- a/lib/utils/os_startup.dart +++ b/lib/utils/os_startup.dart @@ -325,7 +325,7 @@ Exit Future isRegistedStartup(String label) async { await ProcessExecutor.initPowershell(); var shell = 'Get-ScheduledTask | Where-Object {\$_.TaskName -eq "$label"}'; - var process = await Process.run('cmd', ['/C', 'powershell', shell]); + var process = await Process.run('powershell', [shell]); var exist = false; if (process.exitCode == 0) { var existLine = []; @@ -390,7 +390,7 @@ Exit await ProcessExecutor.initPowershell(); var process = await Process.run( - 'cmd', ['/C', 'powershell', '-Command', powershellCommand, '-Wait']); + 'powershell', ['-Command', powershellCommand, '-Wait']); print(process.stdout.toString()); print(process.stderr.toString()); @@ -406,10 +406,8 @@ Exit await ProcessExecutor.initPowershell(); var shell = 'Unregister-ScheduledTask -TaskName "$label" -Confirm:\$false'; var process = await Process.run( - 'cmd', + 'powershell', [ - '/C', - 'powershell', '-Command', 'Start-Process powershell -ArgumentList \'-NoProfile -ExecutionPolicy Bypass -Command "$shell"\' -Verb RunAs -WindowStyle Hidden' ],