Run from Powershell without window being displayed
Hello,
I love this . I have a simple powershell script as
Get Operating System
$os = Get-WmiObject -Class Win32_OperatingSystem $osName = $os.Caption
Run Debloater based on Windows 10 or Windows 11
if ($osName -like "Windows 10") { # Run command for Windows 10 Write-Host "Running Debloater command for Windows 10" & ([scriptblock]::Create((irm "https://debloat.raphi.re/"))) -RunDefaults -Silent & ([scriptblock]::Create((irm "https://debloat.raphi.re/"))) -RunDefaults -Silent -Sysprep & ([scriptblock]::Create((irm "https://debloat.raphi.re/"))) -Silent -RemoveCommApps -RemoveW11Outlook -RemoveGamingApps -DisableDVR -DisableTelemetry -DisableBing -DisableSuggestions -DisableLockscreenTips -DisableWidgets -Sysprep } elseif ($osName -like "Windows 11") { # Run command for Windows 11 Write-Host "Running Debloater command for Windows 11" & ([scriptblock]::Create((irm "https://debloat.raphi.re/"))) -RunDefaults -Silent & ([scriptblock]::Create((irm "https://debloat.raphi.re/"))) -RunDefaults -Silent -Sysprep & ([scriptblock]::Create((irm "https://debloat.raphi.re/"))) -Silent -RemoveCommApps -RemoveW11Outlook -RemoveGamingApps -DisableDVR -ClearStart -ClearStartAllUsers -DisableTelemetry -DisableBing -DisableSuggestions -DisableLockscreenTips -DisableCopilot -DisableRecall -DisableWidgets -TaskbarAlignLeft -ShowSearchIconTb -HideChat & ([scriptblock]::Create((irm "https://debloat.raphi.re/"))) -Silent -RemoveCommApps -RemoveW11Outlook -RemoveGamingApps -DisableDVR -ClearStart -ClearStartAllUsers -DisableTelemetry -DisableBing -DisableSuggestions -DisableLockscreenTips -DisableCopilot -DisableRecall -DisableWidgets -TaskbarAlignLeft -ShowSearchIconTb -HideChat -Sysprep }
End Windows Debloat
=== The above is stored as Win-Debloat Script and when I run through the powershell I still get a powershell window being displayed informing the various actions being taken by the script
Is there a way to completely hide the entire window ?
@shann1976
After looking into this it seems like you can already accomplish this by creating a new powershell process using the -WindowStyle Hidden parameter.
Below is an example executing a local copy of Win11Debloat. Do make sure to change the <PATH> to where you downloaded Win11Debloat to.
Start-Process powershell.exe -WindowStyle Hidden -ArgumentList "-executionpolicy bypass -File <PATH>\Win11Debloat.ps1 -RunDefaults -Silent" -Verb RunAs
I did notice that your script would currently download Win11Debloat all over again every time it runs (up to 4 times). Instead, you could simply copy how the script is downloaded and run here, lines 67 through 102. That should save you some time and make it simpler to hide the powershell windows using the example I provided above. Should be pretty easy to adapt.
Additionally you should be able to combine -RunDefaults with any other parameters, so you only have to run the script twice, instead of 4 times.
Closing this issue, as it's already possible. See my previous post, or the wiki for more info.