Skip to content

Portable Tool for an Ideal Windows Setup

-args for powershell

Greedeks3e12c2ed3363
diff --git a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
index 63cb71a9..b679657c 100644
--- a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
+++ b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
@@ -13,7 +13,7 @@ namespace GTweak.Utilities.Helpers
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = isPowerShell ? "powershell.exe" : "cmd.exe",
- Arguments = arguments,
+ Arguments = isPowerShell ? $"-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"{arguments}\"" : arguments,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
@@ -45,7 +45,7 @@ namespace GTweak.Utilities.Helpers
Process.Start(new ProcessStartInfo()
{
FileName = isPowerShell ? "powershell.exe" : "cmd.exe",
- Arguments = arguments,
+ Arguments = isPowerShell ? $"-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"{arguments}\"" : arguments,
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
});
diff --git a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
index 0e7c6ddd..2635aade 100644
--- a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
+++ b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
@@ -79,6 +79,7 @@ namespace GTweak.Utilities.Tweaks
try
{
var (Alias, IsUnavailable, Scripts) = PackagesDetails[packageName];
+ string argument = "-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command";
using Process process = new Process
{
@@ -92,22 +93,21 @@ namespace GTweak.Utilities.Tweaks
EnableRaisingEvents = true
};
- process.StartInfo.Arguments = $"Get-AppxProvisionedPackage -online | where-object {{$_.PackageName -like '*{packageName}*'}} | Remove-AppxProvisionedPackage -alluser -online –Verbose";
+ process.StartInfo.Arguments = $"{argument} \"Get-AppxProvisionedPackage -online | where-object {{$_.PackageName -like '*{packageName}*'}} | Remove-AppxProvisionedPackage -alluser -online –Verbose\"";
process.Start();
process.WaitForExit();
foreach (string getScript in Scripts)
{
TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $@"cmd.exe /c for /d %i in (""{pathPackage}\*{getScript}*"") do rd /s /q ""%i""");
- process.StartInfo.Arguments = $"Get-AppxPackage -Name {getScript} -AllUsers | Remove-AppxPackage";
+ process.StartInfo.Arguments = $"{argument} \"Get-AppxPackage -Name {getScript} -AllUsers | Remove-AppxPackage\"";
process.Start();
process.WaitForExit();
}
if (!string.IsNullOrEmpty(Alias))
{
- process.StartInfo.Arguments = $"Get-AppxProvisionedPackage -online | where-object {{$_.PackageName -like '*{Alias}*'}} | Remove-AppxProvisionedPackage -alluser -online –Verbose";
- process.Start();
+ process.StartInfo.Arguments = $"{argument} \"Get-AppxProvisionedPackage -online | where-object {{$_.PackageName -like '*{Alias}*'}} | Remove-AppxProvisionedPackage -alluser -online –Verbose\"";
process.WaitForExit();
}
}
@@ -134,7 +134,7 @@ namespace GTweak.Utilities.Tweaks
break;
case "Edge":
string script = $@"
- $region = (Get-ItemProperty -Path 'Registry::HKEY_USERS\.DEFAULT\Control Panel\International\Geo').Name
+ $region = 'TE'
$policyFile = '{StoragePaths.SystemDisk}Windows\System32\IntegratedServicesRegionPolicySet.json'
if (Test-Path $policyFile) {{
@@ -162,7 +162,7 @@ namespace GTweak.Utilities.Tweaks
exit 1
}}";
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} {script}");
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"{script}\"");
foreach (Process process in Process.GetProcessesByName("msedge"))
process.Kill();