Skip to content

Portable Tool for an Ideal Windows Setup

-added CommandExecutor

Greedeks46bb8607b2d4
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csproj
index 61af1163..521df2f6 100644
--- a/.Source/GTweak/GTweak.csproj
+++ b/.Source/GTweak/GTweak.csproj
@@ -266,6 +266,7 @@
</Compile>
<Compile Include="Utilities\Control\BlockRunTweaker.cs" />
<Compile Include="Utilities\Helpers\DisablingWinKeys.cs" />
+ <Compile Include="Utilities\Helpers\CommandExecutor.cs" />
<Compile Include="Utilities\Helpers\TaskSchedulerManager.cs" />
<Compile Include="Utilities\Helpers\UnarchiveManager.cs" />
<Compile Include="Utilities\Helpers\BackgroundQueue.cs" />
diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
index 7db130be..8ea02147 100644
--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
@@ -190,7 +190,7 @@ namespace GTweak.Utilities.Configuration
}
HardwareData["Audio"] = string.Empty;
- using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\cimv2", "SELECT DeviceID, Name, Caption, Description FROM Win32_SoundDevice", new EnumerationOptions { ReturnImmediately = true }))
+ using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\cimv2", "select DeviceID, Name, Caption, Description from Win32_SoundDevice where Status = 'OK'", new EnumerationOptions { ReturnImmediately = true }))
{
foreach (ManagementObject managementObj in searcher.Get().Cast<ManagementObject>())
{
diff --git a/.Source/GTweak/Utilities/Control/BlockRunTweaker.cs b/.Source/GTweak/Utilities/Control/BlockRunTweaker.cs
index bedf07a0..64202f8a 100644
--- a/.Source/GTweak/Utilities/Control/BlockRunTweaker.cs
+++ b/.Source/GTweak/Utilities/Control/BlockRunTweaker.cs
@@ -1,4 +1,5 @@
using GTweak.Utilities.Configuration;
+using GTweak.Utilities.Helpers;
using GTweak.Windows;
using System;
using System.Diagnostics;
@@ -20,13 +21,7 @@ namespace GTweak.Utilities.Control
internal static void CheckingApplicationCopies()
{
- Process.Start(new ProcessStartInfo()
- {
- Arguments = @$"/c timeout /t 10 && del %userprofile%\AppData\Local\CrashDumps\*{SettingsRepository.currentName}*",
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "cmd.exe"
- });
+ CommandExecutor.RunCommand(@$"/c timeout /t 10 && del %userprofile%\AppData\Local\CrashDumps\*{SettingsRepository.currentName}*");
if (!mutex.WaitOne(150, false))
{
diff --git a/.Source/GTweak/Utilities/Control/SettingsRepository.cs b/.Source/GTweak/Utilities/Control/SettingsRepository.cs
index 902dbc00..4f2ff232 100644
--- a/.Source/GTweak/Utilities/Control/SettingsRepository.cs
+++ b/.Source/GTweak/Utilities/Control/SettingsRepository.cs
@@ -165,27 +165,14 @@ namespace GTweak.Utilities.Control
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Tracing\GTweak_RASAPI32");
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Tracing\GTweak_RASMANCS");
- Process.Start(new ProcessStartInfo()
- {
- Arguments = $"/c taskkill /f /im {currentName} & choice /c y /n /d y /t 3 & del {new FileInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath).Name} & " +
- @$"rd /s /q {StoragePaths.FolderLocation} & rd /s /q {Environment.SystemDirectory}\config\systemprofile\AppData\Local\GTweak",
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "cmd.exe"
- });
+
+ CommandExecutor.RunCommand($"/c taskkill /f /im {currentName} & choice /c y /n /d y /t 3 & del {new FileInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath).Name} & " +
+ @$"rd /s /q {StoragePaths.FolderLocation} & rd /s /q {Environment.SystemDirectory}\config\systemprofile\AppData\Local\GTweak");
}
catch (Exception ex) { Debug.WriteLine(ex.Message); }
}
- internal static void SelfReboot()
- {
- Process.Start(new ProcessStartInfo()
- {
- Arguments = $"/c taskkill /f /im \"{currentName}\" & choice /c y /n /d y /t 1 & start \"\" \"{currentLocation}\"",
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "cmd.exe"
- });
- }
+ internal static void SelfReboot() => CommandExecutor.RunCommand($"/c taskkill /f /im \"{currentName}\" & choice /c y /n /d y /t 1 & start \"\" \"{currentLocation}\"");
+
}
}
diff --git a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
new file mode 100644
index 00000000..63cb71a9
--- /dev/null
+++ b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Diagnostics;
+using System.Threading.Tasks;
+
+namespace GTweak.Utilities.Helpers
+{
+ internal sealed class CommandExecutor
+ {
+ internal static async Task<string> GetCommandOutput(string arguments, bool isPowerShell = true)
+ {
+ return await Task.Run(() =>
+ {
+ ProcessStartInfo startInfo = new ProcessStartInfo
+ {
+ FileName = isPowerShell ? "powershell.exe" : "cmd.exe",
+ Arguments = arguments,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ UseShellExecute = false,
+ CreateNoWindow = true
+ };
+
+ using Process process = new Process { StartInfo = startInfo };
+ process.Start();
+
+ string output = process.StandardOutput.ReadToEnd();
+ string error = process.StandardError.ReadToEnd();
+
+ process.WaitForExit();
+
+ if (process.ExitCode == 0)
+ return string.Join(Environment.NewLine, output.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries));
+ else
+ {
+ Debug.WriteLine($"{process.ExitCode}: {error}");
+ return string.Empty;
+ }
+ });
+ }
+
+ internal static async void RunCommand(string arguments, bool isPowerShell = false)
+ {
+ await Task.Run(() =>
+ {
+ Process.Start(new ProcessStartInfo()
+ {
+ FileName = isPowerShell ? "powershell.exe" : "cmd.exe",
+ Arguments = arguments,
+ WindowStyle = ProcessWindowStyle.Hidden,
+ CreateNoWindow = true,
+ });
+ });
+ }
+ }
+}
diff --git a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs
index d9035856..f0bdd758 100644
--- a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs
@@ -177,13 +177,7 @@ namespace GTweak.Utilities.Tweaks
private static async void ClearTempSystemCache()
{
- Process.Start(new ProcessStartInfo()
- {
- Arguments = @$"/c rd /s /q {StoragePaths.SystemDisk}Windows\Temp & rd /s /q %localappdata%\Temp",
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "cmd.exe"
- });
+ CommandExecutor.RunCommand(@$"/c rd /s /q {StoragePaths.SystemDisk}Windows\Temp & rd /s /q %localappdata%\Temp");
foreach (Process process in Process.GetProcesses())
{
@@ -192,14 +186,10 @@ namespace GTweak.Utilities.Tweaks
if (string.Compare(process.MainModule?.FileName, $"{Environment.GetEnvironmentVariable("WINDIR")}\\{"explorer.exe"}", StringComparison.OrdinalIgnoreCase) == 0)
{
process.Kill();
- Process.Start(new ProcessStartInfo()
- {
- Arguments = @"/c attrib -h -r -s IconCache.db & del /a /q ""%localappdata%\IconCache.db"" & del /a /f /q ""%localappdata%\Microsoft\Windows\Explorer\iconcache*""",
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "cmd.exe"
- });
+
+ CommandExecutor.RunCommand(@"/c attrib -h -r -s IconCache.db & del /a /q ""%localappdata%\IconCache.db"" & del /a /f /q ""%localappdata%\Microsoft\Windows\Explorer\iconcache*""");
await Task.Delay(200);
+
process.Start();
}
}
diff --git a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
index 8b7c3c2a..1c77cfb7 100644
--- a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
@@ -428,13 +428,8 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.CreateFolder(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}");
RegistryHelp.CreateFolder(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}");
}
- Process.Start(new ProcessStartInfo()
- {
- Arguments = isChoose ? @"/c rd /s /q ""%userprofile%\3D Objects""" : @"/c mkdir ""%userprofile%\3D Objects""",
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "cmd.exe"
- });
+
+ CommandExecutor.RunCommand(isChoose ? @"/c rd /s /q ""%userprofile%\3D Objects""" : @"/c mkdir ""%userprofile%\3D Objects""");
break;
case "TglButton27":
if (isChoose)
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs
index 6f2f621e..0ddf1a9f 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs
@@ -2,7 +2,6 @@
using GTweak.Utilities.Helpers;
using Microsoft.Win32;
using System;
-using System.Diagnostics;
using System.Management;
using System.Runtime.InteropServices;
using System.Windows;
@@ -82,14 +81,7 @@ namespace GTweak.Utilities.Tweaks
try
{
EnableRecovery();
-
- Process.Start(new ProcessStartInfo()
- {
- Arguments = "/c rstrui.exe",
- FileName = "cmd.exe",
- CreateNoWindow = true,
- WindowStyle = ProcessWindowStyle.Hidden
- });
+ CommandExecutor.RunCommand("/c rstrui.exe");
}
catch { new ViewNotification().Show("", "warn", (string)Application.Current.Resources["notsuccessfulrecovery_notification"]); }
}
@@ -100,13 +92,7 @@ namespace GTweak.Utilities.Tweaks
{
SetTaskState(false, restoreTask);
- Process.Start(new ProcessStartInfo()
- {
- Arguments = "/c sc config wbengine start= disabled && sc config swprv start= disabled && sc config vds start= disabled && sc config VSS start= disabled",
- FileName = "cmd.exe",
- CreateNoWindow = true,
- WindowStyle = ProcessWindowStyle.Hidden
- });
+ CommandExecutor.RunCommand("/c sc config wbengine start= disabled && sc config swprv start= disabled && sc config vds start= disabled && sc config VSS start= disabled");
RegistryHelp.DeleteValue(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients", "{09F7EDC5-294E-4180-AF6A-FB0E6A0E9513}");
@@ -125,13 +111,7 @@ namespace GTweak.Utilities.Tweaks
SetTaskState(true, restoreTask);
- Process.Start(new ProcessStartInfo()
- {
- Arguments = "/c sc config wbengine start= demand && sc config swprv start= demand && sc config vds start= demand && sc config VSS start= demand",
- FileName = "cmd.exe",
- CreateNoWindow = true,
- WindowStyle = ProcessWindowStyle.Hidden
- });
+ CommandExecutor.RunCommand("/c sc config wbengine start= demand && sc config swprv start= demand && sc config vds start= demand && sc config VSS start= demand");
InParams = RestorePoint.GetMethodParameters("Enable");
InParams["WaitTillEnabled"] = true;
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
index 55d4b356..1adcada3 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
@@ -145,36 +145,14 @@ namespace GTweak.Utilities.Tweaks
internal void ViewBluetoothStatus()
{
- try { isBluetoothStatus = new ManagementObjectSearcher("SELECT DeviceId FROM Win32_PnPEntity WHERE service='BthLEEnum'").Get().Count > 0; }
+ try { isBluetoothStatus = new ManagementObjectSearcher("select DeviceId from Win32_PnPEntity where service='BthLEEnum'").Get().Count > 0; }
catch { isBluetoothStatus = false; }
}
- internal void ViewNetshState()
+ internal async void ViewNetshState()
{
- Task.Run(delegate
- {
- string getStateNetsh = default;
-
- ProcessStartInfo startInfo = new ProcessStartInfo
- {
- FileName = @"cmd.exe",
- Arguments = $"/c chcp 65001 & netsh int teredo show state & netsh int ipv6 isatap show state & netsh int isatap show state & netsh int ipv6 6to4 show state",
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- UseShellExecute = false,
- CreateNoWindow = true
- };
-
- using Process process = new Process() { StartInfo = startInfo, EnableRaisingEvents = true };
-
- process.Start();
-
- getStateNetsh = process.StandardOutput.ReadToEnd();
-
- process.Close();
-
- isNetshState = getStateNetsh.Contains("default") || getStateNetsh.Contains("enabled");
- });
+ string getStateNetsh = await CommandExecutor.GetCommandOutput("/c chcp 65001 & netsh int teredo show state & netsh int ipv6 isatap show state & netsh int isatap show state & netsh int ipv6 6to4 show state", false);
+ isNetshState = getStateNetsh.Contains("default") || getStateNetsh.Contains("enabled");
}
[DllImport("user32.dll")]
@@ -310,17 +288,7 @@ namespace GTweak.Utilities.Tweaks
argStateNetsh = @"default";
}
- Task.Run(() =>
- {
- Process.Start(new ProcessStartInfo()
- {
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- UseShellExecute = false,
- FileName = "cmd.exe",
- Arguments = $"/c netsh int teredo set state {argStateNetsh} & netsh int ipv6 6to4 set state state = {argStateNetsh} undoonstop = {argStateNetsh} & netsh int ipv6 isatap set state state = {argStateNetsh} & netsh int ipv6 set privacy state = {argStateNetshSecond} & netsh int ipv6 set global randomizeidentifier = {argStateNetshSecond} & netsh int isatap set state {argStateNetsh}"
- });
- });
+ CommandExecutor.RunCommand($"/c netsh int teredo set state {argStateNetsh} & netsh int ipv6 6to4 set state state = {argStateNetsh} undoonstop = {argStateNetsh} & netsh int ipv6 isatap set state state = {argStateNetsh} & netsh int ipv6 set privacy state = {argStateNetshSecond} & netsh int ipv6 set global randomizeidentifier = {argStateNetshSecond} & netsh int isatap set state {argStateNetsh}");
break;
case "TglButton14":
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", "LargeSystemCache", isChoose ? 1 : 0, RegistryValueKind.DWord);
@@ -359,13 +327,7 @@ namespace GTweak.Utilities.Tweaks
break;
case "TglButton20":
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\mpssvc", "Start", isChoose ? 4 : 2, RegistryValueKind.DWord);
- Process.Start(new ProcessStartInfo()
- {
- Arguments = $"/c netsh advfirewall set allprofiles state {(isChoose ? "off" : "on")}",
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "cmd.exe"
- });
+ CommandExecutor.RunCommand($"/c netsh advfirewall set allprofiles state {(isChoose ? "off" : "on")}");
break;
case "TglButton21":
RegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\GameBar", "AutoGameModeEnabled", isChoose ? 0 : 1, RegistryValueKind.DWord);
@@ -381,11 +343,7 @@ namespace GTweak.Utilities.Tweaks
private static void BluetoothStatusSet(string status)
{
- Task.Run(() =>
- {
- Process.Start(new ProcessStartInfo()
- {
- Arguments = @"Add-Type -AssemblyName System.Runtime.WindowsRuntime
+ CommandExecutor.RunCommand(@"Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
@@ -399,12 +357,7 @@ namespace GTweak.Utilities.Tweaks
$radios = Await ([Windows.Devices.Radios.Radio]::GetRadiosAsync()) ([System.Collections.Generic.IReadOnlyList[Windows.Devices.Radios.Radio]])
$bluetooth = $radios | ? { $_.Kind -eq 'Bluetooth' }
[Windows.Devices.Radios.RadioState,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
- Await ($bluetooth.SetStateAsync(" + status + ")) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null",
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "powershell.exe"
- });
- });
+ Await ($bluetooth.SetStateAsync(" + status + ")) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null", true);
}
@@ -468,13 +421,7 @@ namespace GTweak.Utilities.Tweaks
_powercfg.Start();
}
- Process.Start(new ProcessStartInfo()
- {
- Arguments = $"/c timeout /t 10 && rd /s /q {StoragePaths.FolderLocation}",
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "cmd.exe"
- });
+ CommandExecutor.RunCommand($"/c timeout /t 10 && rd /s /q {StoragePaths.FolderLocation}");
}
}
else
diff --git a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
index 2848a4ad..8ec72d93 100644
--- a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
+++ b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
@@ -119,28 +119,7 @@ namespace GTweak.Utilities.Tweaks
};
#endregion
- internal void ViewInstalledPackages()
- {
- ProcessStartInfo startInfo = new ProcessStartInfo
- {
- FileName = "powershell.exe",
- Arguments = "Get-AppxPackage | Select-Object -ExpandProperty Name",
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- UseShellExecute = false,
- CreateNoWindow = true
- };
-
- using Process process = new Process { StartInfo = startInfo };
- process.Start();
-
- string output = process.StandardOutput.ReadToEnd();
-
- process.WaitForExit();
-
- if (process.ExitCode == 0)
- InstalledPackages = string.Join(Environment.NewLine, output.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries));
- }
+ internal async void ViewInstalledPackages() => InstalledPackages = await CommandExecutor.GetCommandOutput("Get-AppxPackage | Select-Object -ExpandProperty Name");
internal static void DeletingPackage(string packageName)
{
@@ -228,13 +207,7 @@ namespace GTweak.Utilities.Tweaks
if (isLocalAccount)
argumentsFolders += @" & rd /s /q %userprofile%\OneDrive";
- Process.Start(new ProcessStartInfo()
- {
- Arguments = argumentsFolders,
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "cmd.exe"
- });
+ CommandExecutor.RunCommand(argumentsFolders);
}
internal static void ResetOneDrive()
@@ -255,26 +228,10 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.CreateFolder(Registry.ClassesRoot, @"Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}");
}
- internal void CheckingForLocalAccount()
+ internal async void CheckingForLocalAccount()
{
- ProcessStartInfo startInfo = new ProcessStartInfo
- {
- FileName = @"powershell.exe",
- Arguments = @"Get-LocalUser | Where-Object { $_.Enabled -match 'True'} | Select-Object -ExpandProperty PrincipalSource",
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- UseShellExecute = false,
- CreateNoWindow = true
- };
-
- Process process = new Process() { StartInfo = startInfo, EnableRaisingEvents = true };
-
- process.Start();
-
- isLocalAccount = !process.StandardOutput.ReadToEnd().Contains("MicrosoftAccount");
-
- process.Close();
- process.Dispose();
+ string output = await CommandExecutor.GetCommandOutput("Get-LocalUser | Where-Object { $_.Enabled -match 'True'} | Select-Object -ExpandProperty PrincipalSource");
+ isLocalAccount = !output.Contains("MicrosoftAccount");
}
}
}
diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
index 4b084c5c..654d5da9 100644
--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs
+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
@@ -1,7 +1,7 @@
using GTweak.Utilities.Control;
+using GTweak.Utilities.Helpers;
using System;
using System.ComponentModel;
-using System.Diagnostics;
using System.Media;
using System.Windows;
using System.Windows.Controls;
@@ -44,16 +44,10 @@ namespace GTweak.Windows
{
if (e.LeftButton == MouseButtonState.Pressed && !string.IsNullOrEmpty(ActionNotice))
{
- Process.Start(new ProcessStartInfo()
+ CommandExecutor.RunCommand(ActionNotice switch
{
- Arguments = ActionNotice switch
- {
- "logout" => @"/c logoff",
- _ => @"/c shutdown /r /t 0",
- },
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "cmd.exe"
+ "logout" => @"/c logoff",
+ _ => @"/c shutdown /r /t 0",
});
}
}
diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml.cs b/.Source/GTweak/Windows/UpdateWindow.xaml.cs
index 7bd48548..151286be 100644
--- a/.Source/GTweak/Windows/UpdateWindow.xaml.cs
+++ b/.Source/GTweak/Windows/UpdateWindow.xaml.cs
@@ -1,4 +1,5 @@
using GTweak.Utilities.Control;
+using GTweak.Utilities.Helpers;
using System;
using System.ComponentModel;
using System.Diagnostics;
@@ -75,13 +76,7 @@ namespace GTweak.Windows
};
webClient.DownloadFileCompleted += delegate
{
- Process.Start(new ProcessStartInfo()
- {
- Arguments = $"/c taskkill /f /im \"{SettingsRepository.currentName}\" && timeout /t 1 && del \"{SettingsRepository.currentLocation}\" && ren Git-GTweak.exe \"{SettingsRepository.currentName}\" && \"{SettingsRepository.currentLocation}\"",
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- FileName = "cmd.exe"
- });
+ CommandExecutor.RunCommand($"/c taskkill /f /im \"{SettingsRepository.currentName}\" && timeout /t 1 && del \"{SettingsRepository.currentLocation}\" && ren Git-GTweak.exe \"{SettingsRepository.currentName}\" && \"{SettingsRepository.currentLocation}\"");
};
webClient.DownloadFileAsync(new Uri("https://github.com/Greedeks/GTweak/releases/latest/download/GTweak.exe"), "Git-GTweak.exe");
}