2022-10-04 21:10:29 +02:00
# Requires -RunAsAdministrator
2020-11-07 02:57:38 +01:00
[ CmdletBinding ( SupportsShouldProcess ) ]
2024-01-31 22:19:50 +01:00
param (
2024-03-11 23:38:19 +01:00
[ switch ] $Silent ,
[ switch ] $RunAppConfigurator ,
[ switch ] $RunDefaults , [ switch ] $RunWin11Defaults ,
[ switch ] $RemoveApps ,
[ switch ] $RemoveAppsCustom ,
[ switch ] $RemoveGamingApps ,
[ switch ] $RemoveCommApps ,
[ switch ] $RemoveDevApps ,
[ switch ] $RemoveW11Outlook ,
2024-05-24 14:13:15 +02:00
[ switch ] $DisableDVR ,
2024-03-11 23:38:19 +01:00
[ switch ] $DisableTelemetry ,
[ switch ] $DisableBingSearches , [ switch ] $DisableBing ,
[ switch ] $DisableLockscrTips , [ switch ] $DisableLockscreenTips ,
[ switch ] $DisableWindowsSuggestions , [ switch ] $DisableSuggestions ,
[ switch ] $ShowHiddenFolders ,
[ switch ] $ShowKnownFileExt ,
[ switch ] $HideDupliDrive ,
[ switch ] $TaskbarAlignLeft ,
[ switch ] $HideSearchTb , [ switch ] $ShowSearchIconTb , [ switch ] $ShowSearchLabelTb , [ switch ] $ShowSearchBoxTb ,
[ switch ] $HideTaskview ,
[ switch ] $DisableCopilot ,
2024-06-05 09:17:24 +02:00
[ switch ] $DisableRecall ,
2024-03-11 23:38:19 +01:00
[ switch ] $DisableWidgets ,
[ switch ] $HideWidgets ,
[ switch ] $DisableChat ,
[ switch ] $HideChat ,
[ switch ] $ClearStart ,
[ switch ] $RevertContextMenu ,
[ switch ] $DisableOnedrive , [ switch ] $HideOnedrive ,
[ switch ] $Disable3dObjects , [ switch ] $Hide3dObjects ,
[ switch ] $DisableMusic , [ switch ] $HideMusic ,
[ switch ] $DisableIncludeInLibrary , [ switch ] $HideIncludeInLibrary ,
[ switch ] $DisableGiveAccessTo , [ switch ] $HideGiveAccessTo ,
[ switch ] $DisableShare , [ switch ] $HideShare
2020-11-07 02:57:38 +01:00
)
2023-08-03 22:24:27 +02:00
2024-03-04 00:10:24 +01:00
# Shows application selection form that allows the user to select what apps they want to remove or keep
function ShowAppSelectionForm {
[ reflection.assembly ] :: loadwithpartialname ( " System.Windows.Forms " ) | Out-Null
[ reflection.assembly ] :: loadwithpartialname ( " System.Drawing " ) | Out-Null
# Initialise form objects
$form = New-Object System . Windows . Forms . Form
$label = New-Object System . Windows . Forms . Label
$button1 = New-Object System . Windows . Forms . Button
$button2 = New-Object System . Windows . Forms . Button
$selectionBox = New-Object System . Windows . Forms . CheckedListBox
2024-03-04 12:56:12 +01:00
$loadingLabel = New-Object System . Windows . Forms . Label
$onlyInstalledCheckBox = New-Object System . Windows . Forms . CheckBox
2024-04-05 23:35:10 +02:00
$checkUncheckCheckBox = New-Object System . Windows . Forms . CheckBox
2024-03-04 12:56:12 +01:00
$initialFormWindowState = New-Object System . Windows . Forms . FormWindowState
2024-03-04 00:10:24 +01:00
2024-04-05 23:35:10 +02:00
$global:selectionBoxIndex = -1
2024-03-04 00:10:24 +01:00
# saveButton eventHandler
$handler_saveButton_Click =
{
$global:SelectedApps = $selectionBox . CheckedItems
# Create file that stores selected apps if it doesn't exist
if ( ! ( Test-Path " $PSScriptRoot /CustomAppsList " ) ) {
$null = New-Item " $PSScriptRoot /CustomAppsList "
}
Set-Content -Path " $PSScriptRoot /CustomAppsList " -Value $global:SelectedApps
$form . Close ( )
}
# cancelButton eventHandler
$handler_cancelButton_Click =
{
$form . Close ( )
}
2024-04-05 23:35:10 +02:00
$selectionBox_SelectedIndexChanged =
{
$global:selectionBoxIndex = $selectionBox . SelectedIndex
}
$selectionBox_MouseDown =
{
if ( $_ . Button -eq [ System.Windows.Forms.MouseButtons ] :: Left ) {
if ( [ System.Windows.Forms.Control ] :: ModifierKeys -eq [ System.Windows.Forms.Keys ] :: Shift ) {
if ( $global:selectionBoxIndex -ne -1 ) {
$topIndex = $global:selectionBoxIndex
if ( $selectionBox . SelectedIndex -gt $topIndex ) {
for ( ( $i = ( $topIndex ) ) ; $i -le $selectionBox . SelectedIndex ; $i + + ) {
$selectionBox . SetItemChecked ( $i , $selectionBox . GetItemChecked ( $topIndex ) )
}
}
elseif ( $topIndex -gt $selectionBox . SelectedIndex ) {
for ( ( $i = ( $selectionBox . SelectedIndex ) ) ; $i -le $topIndex ; $i + + ) {
$selectionBox . SetItemChecked ( $i , $selectionBox . GetItemChecked ( $topIndex ) )
}
}
}
}
elseif ( $global:selectionBoxIndex -ne $selectionBox . SelectedIndex ) {
$selectionBox . SetItemChecked ( $selectionBox . SelectedIndex , -not $selectionBox . GetItemChecked ( $selectionBox . SelectedIndex ) )
}
}
}
$check_All =
{
for ( ( $i = 0 ) ; $i -lt $selectionBox . Items . Count ; $i + + ) {
$selectionBox . SetItemChecked ( $i , $checkUncheckCheckBox . Checked )
}
}
2024-03-04 12:56:12 +01:00
$load_Apps =
2024-03-04 00:10:24 +01:00
{
2024-03-04 12:56:12 +01:00
# Correct the initial state of the form to prevent the .Net maximized form issue
$form . WindowState = $initialFormWindowState
2024-04-05 23:35:10 +02:00
# Reset state to default before loading appslist again
$global:selectionBoxIndex = -1
$checkUncheckCheckBox . Checked = $False
2024-03-04 12:56:12 +01:00
# Show loading indicator
$loadingLabel . Visible = $true
$form . Refresh ( )
# Clear selectionBox before adding any new items
$selectionBox . Items . Clear ( )
# Set filePath where Appslist can be found
$appsFile = " $PSScriptRoot /Appslist.txt "
2024-03-29 16:56:29 +01:00
$listOfApps = " "
if ( $onlyInstalledCheckBox . Checked -and ( $global:wingetInstalled -eq $true ) ) {
2024-04-01 14:07:59 +02:00
# Attempt to get a list of installed apps via winget, times out after 10 seconds
$job = Start-Job { return winget list - -accept -source -agreements - -disable -interactivity }
$jobDone = $job | Wait-Job -TimeOut 10
if ( -not $jobDone ) {
# Show error that the script was unable to get list of apps from winget
[ System.Windows.MessageBox ] :: Show ( 'Unable to load list of installed apps via winget, some apps may not be displayed in the list.' , 'Error' , 'Ok' , 'Error' )
}
else {
# Add output of job (list of apps) to $listOfApps
$listOfApps = Receive-Job -Job $job
}
2024-03-29 16:56:29 +01:00
}
2024-03-04 12:56:12 +01:00
# Go through appslist and add items one by one to the selectionBox
Foreach ( $app in ( Get-Content -Path $appsFile | Where-Object { $_ -notmatch '^\s*$' } ) ) {
$appChecked = $true
# Remove first # if it exists and set AppChecked to false
if ( $app . StartsWith ( '#' ) ) {
$app = $app . TrimStart ( " # " )
$appChecked = $false
}
# Remove any comments from the Appname
if ( -not ( $app . IndexOf ( '#' ) -eq -1 ) ) {
$app = $app . Substring ( 0 , $app . IndexOf ( '#' ) )
}
# Remove any remaining spaces from the Appname
if ( -not ( $app . IndexOf ( ' ' ) -eq -1 ) ) {
$app = $app . Substring ( 0 , $app . IndexOf ( ' ' ) )
}
$appString = $app . Trim ( '*' )
# Make sure appString is not empty
if ( $appString . length -gt 0 ) {
2024-03-29 16:56:29 +01:00
if ( $onlyInstalledCheckBox . Checked ) {
# onlyInstalledCheckBox is checked, check if app is installed before adding it to selectionBox
2024-05-20 13:09:08 +02:00
if ( $listOfApps -like ( " * " + $appString + " * " ) ) {
2024-03-29 16:56:29 +01:00
$installed = " installed "
}
elseif ( ( $appString -eq " Microsoft.Edge " ) -and ( $listOfApps -like " * XPFFTQ037JWMHS * " ) ) {
$installed = " installed "
}
else {
$installed = Get-AppxPackage -Name $app
}
2024-03-04 12:56:12 +01:00
2024-03-29 16:56:29 +01:00
if ( $installed . length -eq 0 ) {
2024-03-04 12:56:12 +01:00
# App is not installed, continue to next item without adding this app to the selectionBox
continue
}
}
# Add the app to the selectionBox and set it's checked status
$selectionBox . Items . Add ( $appString , $appChecked ) | Out-Null
}
}
# Hide loading indicator
2024-04-05 23:35:10 +02:00
$loadingLabel . Visible = $False
2024-03-04 12:56:12 +01:00
# Sort selectionBox alphabetically
2024-04-05 23:35:10 +02:00
$selectionBox . Sorted = $True
2024-03-04 00:10:24 +01:00
}
$form . Text = " Win11Debloat Application Selection "
$form . Name = " appSelectionForm "
$form . DataBindings . DefaultDataSourceUpdateMode = 0
2024-04-05 23:35:10 +02:00
$form . ClientSize = New-Object System . Drawing . Size ( 400 , 502 )
2024-03-04 12:56:12 +01:00
$form . FormBorderStyle = 'FixedDialog'
2024-04-05 23:35:10 +02:00
$form . MaximizeBox = $False
2024-03-04 00:10:24 +01:00
$button1 . TabIndex = 4
$button1 . Name = " saveButton "
$button1 . DialogResult = [ System.Windows.Forms.DialogResult ] :: OK
$button1 . UseVisualStyleBackColor = $True
2024-03-29 16:56:29 +01:00
$button1 . Text = " Confirm "
2024-04-05 23:35:10 +02:00
$button1 . Location = New-Object System . Drawing . Point ( 27 , 472 )
2024-03-04 00:10:24 +01:00
$button1 . Size = New-Object System . Drawing . Size ( 75 , 23 )
$button1 . DataBindings . DefaultDataSourceUpdateMode = 0
$button1 . add_Click ( $handler_saveButton_Click )
$form . Controls . Add ( $button1 )
$button2 . TabIndex = 5
$button2 . Name = " cancelButton "
$button2 . DialogResult = [ System.Windows.Forms.DialogResult ] :: Cancel
$button2 . UseVisualStyleBackColor = $True
$button2 . Text = " Cancel "
2024-04-05 23:35:10 +02:00
$button2 . Location = New-Object System . Drawing . Point ( 129 , 472 )
2024-03-04 00:10:24 +01:00
$button2 . Size = New-Object System . Drawing . Size ( 75 , 23 )
$button2 . DataBindings . DefaultDataSourceUpdateMode = 0
$button2 . add_Click ( $handler_cancelButton_Click )
$form . Controls . Add ( $button2 )
2024-03-04 12:56:12 +01:00
$label . Location = New-Object System . Drawing . Point ( 13 , 5 )
2024-04-05 23:35:10 +02:00
$label . Size = New-Object System . Drawing . Size ( 400 , 14 )
$Label . Font = 'Microsoft Sans Serif,8'
2024-03-04 12:56:12 +01:00
$label . Text = 'Check apps that you wish to remove, uncheck apps that you wish to keep'
2024-03-04 00:10:24 +01:00
$form . Controls . Add ( $label )
2024-04-05 23:35:10 +02:00
$loadingLabel . Location = New-Object System . Drawing . Point ( 16 , 46 )
2024-03-29 16:56:29 +01:00
$loadingLabel . Size = New-Object System . Drawing . Size ( 300 , 418 )
$loadingLabel . Text = 'Loading apps...'
2024-03-04 12:56:12 +01:00
$loadingLabel . BackColor = " White "
$loadingLabel . Visible = $false
$form . Controls . Add ( $loadingLabel )
$onlyInstalledCheckBox . TabIndex = 6
2024-04-05 23:35:10 +02:00
$onlyInstalledCheckBox . Location = New-Object System . Drawing . Point ( 230 , 474 )
2024-03-04 12:56:12 +01:00
$onlyInstalledCheckBox . Size = New-Object System . Drawing . Size ( 150 , 20 )
$onlyInstalledCheckBox . Text = 'Only show installed apps'
$onlyInstalledCheckBox . add_CheckedChanged ( $load_Apps )
$form . Controls . Add ( $onlyInstalledCheckBox )
2024-04-05 23:35:10 +02:00
$checkUncheckCheckBox . TabIndex = 7
$checkUncheckCheckBox . Location = New-Object System . Drawing . Point ( 16 , 22 )
$checkUncheckCheckBox . Size = New-Object System . Drawing . Size ( 150 , 20 )
$checkUncheckCheckBox . Text = 'Check/Uncheck all'
$checkUncheckCheckBox . add_CheckedChanged ( $check_All )
$form . Controls . Add ( $checkUncheckCheckBox )
2024-03-04 00:10:24 +01:00
$selectionBox . FormattingEnabled = $True
$selectionBox . DataBindings . DefaultDataSourceUpdateMode = 0
$selectionBox . Name = " selectionBox "
2024-04-05 23:35:10 +02:00
$selectionBox . Location = New-Object System . Drawing . Point ( 13 , 43 )
2024-03-04 00:10:24 +01:00
$selectionBox . Size = New-Object System . Drawing . Size ( 374 , 424 )
$selectionBox . TabIndex = 3
2024-04-05 23:35:10 +02:00
$selectionBox . add_SelectedIndexChanged ( $selectionBox_SelectedIndexChanged )
$selectionBox . add_Click ( $selectionBox_MouseDown )
2024-03-04 00:10:24 +01:00
$form . Controls . Add ( $selectionBox )
# Save the initial state of the form
2024-03-04 12:56:12 +01:00
$initialFormWindowState = $form . WindowState
2024-03-04 00:10:24 +01:00
2024-03-04 12:56:12 +01:00
# Load apps into selectionBox
$form . add_Load ( $load_Apps )
2024-03-04 00:10:24 +01:00
# Focus selectionBox when form opens
$form . Add_Shown ( { $form . Activate ( ) ; $selectionBox . Focus ( ) } )
# Show the Form
return $form . ShowDialog ( )
}
2023-08-03 22:24:27 +02:00
# Reads list of apps from file and removes them for all user accounts and from the OS image.
2024-03-29 16:56:29 +01:00
function RemoveAppsFromFile {
2024-01-31 22:19:50 +01:00
param (
2024-03-29 16:56:29 +01:00
$appsFilePath
2023-08-03 01:18:02 +02:00
)
2024-03-29 16:56:29 +01:00
$appsList = @ ( )
Write-Output " > Removing default selection of apps... "
2020-10-27 23:26:39 +01:00
2023-08-03 22:24:27 +02:00
# Get list of apps from file at the path provided, and remove them one by one
2024-03-29 16:56:29 +01:00
Foreach ( $app in ( Get-Content -Path $appsFilePath | Where-Object { $_ -notmatch '^#.*' -and $_ -notmatch '^\s*$' } ) ) {
2023-08-03 22:24:27 +02:00
# Remove any spaces before and after the Appname
2023-08-02 21:58:09 +02:00
$app = $app . Trim ( )
2023-07-18 16:03:22 +02:00
2023-08-03 22:24:27 +02:00
# Remove any comments from the Appname
2023-09-29 02:39:56 +02:00
if ( -not ( $app . IndexOf ( '#' ) -eq -1 ) ) {
2023-08-02 21:58:09 +02:00
$app = $app . Substring ( 0 , $app . IndexOf ( '#' ) )
}
2023-08-03 22:24:27 +02:00
# Remove any remaining spaces from the Appname
2023-09-29 02:39:56 +02:00
if ( -not ( $app . IndexOf ( ' ' ) -eq -1 ) ) {
2023-08-02 21:58:09 +02:00
$app = $app . Substring ( 0 , $app . IndexOf ( ' ' ) )
}
2020-11-02 20:01:00 +01:00
2023-08-03 22:40:19 +02:00
$appString = $app . Trim ( '*' )
2024-03-29 16:56:29 +01:00
$appsList + = $appString
2020-10-27 23:26:39 +01:00
}
2023-10-15 19:48:27 +02:00
2024-03-29 16:56:29 +01:00
RemoveApps $appsList
2020-10-27 23:26:39 +01:00
}
2023-08-03 22:24:27 +02:00
2023-11-19 23:40:35 +01:00
# Removes apps specified during function call from all user accounts and from the OS image.
2024-03-29 16:56:29 +01:00
function RemoveApps {
2024-01-31 22:19:50 +01:00
param (
2023-11-19 23:40:35 +01:00
$appslist
)
2024-01-31 22:19:50 +01:00
Foreach ( $app in $appsList ) {
2024-03-04 12:56:12 +01:00
Write-Output " Attempting to remove $app ... "
2024-03-29 16:56:29 +01:00
if ( ( $app -eq " Microsoft.OneDrive " ) -or ( $app -eq " Microsoft.Edge " ) ) {
# Use winget to remove OneDrive and Edge
if ( $global:wingetInstalled -eq $false ) {
2024-05-05 06:20:19 -04:00
Write-Host " WinGet is either not installed or is outdated, so $app could not be removed " -ForegroundColor Red
2024-03-29 16:56:29 +01:00
}
else {
# Uninstall app via winget
2024-04-01 14:07:59 +02:00
winget uninstall - -accept -source -agreements - -disable -interactivity - -id $app
2024-03-29 16:56:29 +01:00
}
}
else {
# Use Remove-AppxPackage to remove all other apps
$app = '*' + $app + '*'
2023-11-19 23:40:35 +01:00
2024-03-29 16:56:29 +01:00
# Remove installed app for all existing users
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -AllUsers
2023-11-19 23:40:35 +01:00
2024-03-29 16:56:29 +01:00
# Remove provisioned app from OS image, so the app won't be installed for any new users
Get-AppxProvisionedPackage -Online | Where-Object { $_ . PackageName -like $app } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_ . PackageName }
}
2023-11-19 23:40:35 +01:00
}
}
2022-04-09 18:52:16 +02:00
# Import & execute regfile
2023-05-15 16:38:11 -06:00
function RegImport {
2024-01-31 22:19:50 +01:00
param (
2023-12-15 13:22:35 +01:00
$message ,
$path
2020-11-07 02:57:38 +01:00
)
2020-11-04 01:48:42 +01:00
2023-12-15 13:22:35 +01:00
Write-Output $message
2020-11-07 02:57:38 +01:00
reg import $path
2023-10-15 19:48:27 +02:00
Write-Output " "
2020-11-04 01:48:42 +01:00
}
2023-08-03 22:24:27 +02:00
2024-06-05 19:53:59 +02:00
# Restart the Windows explorer process
2023-09-08 00:47:59 +02:00
function RestartExplorer {
2024-02-23 12:25:11 +01:00
Write-Output " > Restarting Windows explorer to apply all changes. Note: This may cause some flickering. "
2023-09-08 00:47:59 +02:00
2024-06-05 19:18:01 +02:00
# Only restart if the powershell process matches the OS architecture
# Restarting explorer from a 32bit Powershell window will fail on a 64bit OS
if ( [ Environment ] :: Is64BitProcess -eq [ Environment ] :: Is64BitOperatingSystem )
{
2024-06-05 19:53:59 +02:00
Stop-Process -processName: Explorer -Force
2024-06-05 19:18:01 +02:00
}
else {
Write-Warning " Unable to restart Windows Explorer, please manually restart your PC to apply all changes. "
}
2023-09-08 00:47:59 +02:00
}
# Clear all pinned apps from the start menu.
# Credit: https://lazyadmin.nl/win-11/customize-windows-11-start-menu-layout/
function ClearStartMenu {
2024-01-31 22:19:50 +01:00
param (
2023-09-08 00:47:59 +02:00
$message
)
Write-Output $message
# Path to start menu template
2023-09-08 01:06:01 +02:00
$startmenuTemplate = " $PSScriptRoot /Start/start2.bin "
2023-09-08 00:47:59 +02:00
2024-05-14 23:56:58 +02:00
# Check if template bin file exists, return early if it doesn't
if ( -not ( Test-Path $startmenuTemplate ) ) {
Write-Host " Error: Unable to clear start menu, start2.bin file missing from script folder " -ForegroundColor Red
Write-Output " "
return
}
2023-09-08 00:47:59 +02:00
# Get all user profile folders
$usersStartMenu = get-childitem -path " C:\Users\*\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState "
# Copy Start menu to all users folders
ForEach ( $startmenu in $usersStartMenu ) {
$startmenuBinFile = $startmenu . Fullname + " \start2.bin "
2024-05-24 14:13:15 +02:00
$backupBinFile = $startmenuBinFile + " .bak "
2023-09-08 00:47:59 +02:00
# Check if bin file exists
2024-03-29 16:56:29 +01:00
if ( Test-Path $startmenuBinFile ) {
2024-05-24 14:13:15 +02:00
# Backup current startmenu file
Move-Item -Path $startmenuBinFile -Destination $backupBinFile
# Copy template file
2023-09-08 00:47:59 +02:00
Copy-Item -Path $startmenuTemplate -Destination $startmenu -Force
2023-09-12 02:59:25 +02:00
$cpyMsg = " Replaced start menu for user " + $startmenu . Fullname . Split ( " \ " ) [ 2 ]
Write-Output $cpyMsg
2023-09-08 00:47:59 +02:00
}
else {
2024-01-31 22:19:50 +01:00
# Bin file doesn't exist, indicating the user is not running the correct version of Windows. Exit function
2024-05-14 23:56:58 +02:00
Write-Host " Error: Unable to clear start menu, start2.bin file could not found for user " $startmenu . Fullname . Split ( " \ " ) [ 2 ] -ForegroundColor Red
Write-Output " "
2023-09-08 00:47:59 +02:00
return
}
}
# Also apply start menu template to the default profile
# Path to default profile
$defaultProfile = " C:\Users\default\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState "
# Create folder if it doesn't exist
2024-01-31 22:19:50 +01:00
if ( -not ( Test-Path $defaultProfile ) ) {
2023-09-12 02:59:25 +02:00
new-item $defaultProfile -ItemType Directory -Force | Out-Null
Write-Output " Created LocalState folder for default user "
2023-09-08 00:47:59 +02:00
}
# Copy template to default profile
Copy-Item -Path $startmenuTemplate -Destination $defaultProfile -Force
2023-09-12 02:59:25 +02:00
Write-Output " Copied start menu template to default user folder "
2023-12-15 13:22:35 +01:00
Write-Output " "
}
# Add parameter to script and write to file
function AddParameter {
2024-01-31 22:19:50 +01:00
param (
2023-12-15 13:22:35 +01:00
$parameterName ,
$message
)
# Add key if it doesn't already exist
2024-03-01 13:54:02 +01:00
if ( -not $global:Params . ContainsKey ( $parameterName ) ) {
$global:Params . Add ( $parameterName , $true )
2023-12-15 13:22:35 +01:00
}
# Create or clear file that stores last used settings
2024-03-29 16:56:29 +01:00
if ( ! ( Test-Path " $PSScriptRoot /SavedSettings " ) ) {
$null = New-Item " $PSScriptRoot /SavedSettings "
2023-12-15 13:22:35 +01:00
}
elseif ( $global:FirstSelection ) {
2024-03-29 16:56:29 +01:00
$null = Clear-Content " $PSScriptRoot /SavedSettings "
2023-12-15 13:22:35 +01:00
}
2024-02-23 12:25:11 +01:00
$global:FirstSelection = $false
2023-12-15 13:22:35 +01:00
# Create entry and add it to the file
$entry = $parameterName + " #- " + $message
2024-03-29 16:56:29 +01:00
Add-Content -Path " $PSScriptRoot /SavedSettings " -Value $entry
2023-12-15 13:22:35 +01:00
}
function PrintHeader {
2024-01-31 22:19:50 +01:00
param (
2023-12-15 13:22:35 +01:00
$title
)
$fullTitle = " Win11Debloat Script - " + $title
Clear-Host
Write-Output " ------------------------------------------------------------------------------------------- "
Write-Output $fullTitle
Write-Output " ------------------------------------------------------------------------------------------- "
}
function PrintFromFile {
2024-01-31 22:19:50 +01:00
param (
2023-12-15 13:22:35 +01:00
$path
)
Clear-Host
# Get & print script menu from file
Foreach ( $line in ( Get-Content -Path $path ) ) {
Write-Output $line
}
2023-09-08 00:47:59 +02:00
}
2024-04-05 18:26:58 +02:00
function AwaitKeyToExit {
# Suppress prompt if Silent parameter was passed
if ( -not $Silent ) {
Write-Output " "
Write-Output " Press any key to exit... "
$null = [ System.Console ] :: ReadKey ( )
}
}
2024-05-05 06:20:19 -04:00
# Check if winget is installed & if it is, check if the version is at least v1.4
if ( ( Get-AppxPackage -Name " *Microsoft.DesktopAppInstaller* " ) -and ( ( winget -v ) -replace 'v' , '' -gt 1.4 ) ) {
2024-03-29 16:56:29 +01:00
$global:wingetInstalled = $true
}
2024-04-01 14:07:59 +02:00
else {
2024-03-29 16:56:29 +01:00
$global:wingetInstalled = $false
2024-05-05 06:20:19 -04:00
# Show warning that requires user confirmation, Suppress confirmation if Silent parameter was passed
if ( -not $Silent ) {
Write-Warning " Winget is not installed or outdated. This may prevent Win11Debloat from removing certain apps. "
Write-Output " "
Write-Output " Press any key to continue anyway... "
Read-Host | Out-Null
}
2024-03-29 16:56:29 +01:00
}
2024-03-04 12:56:12 +01:00
# Hide progress bars for app removal, as they block Win11Debloat's output
$ProgressPreference = 'SilentlyContinue'
2024-04-05 23:35:10 +02:00
$global:Params = $PSBoundParameters
2024-03-01 13:54:02 +01:00
$global:FirstSelection = $true
2023-09-28 16:11:04 +02:00
$SPParams = 'WhatIf' , 'Confirm' , 'Verbose' , 'Silent'
2023-09-27 21:03:25 +02:00
$SPParamCount = 0
2024-03-01 13:54:02 +01:00
# Count how many SPParams exist within Params
2024-03-29 16:56:29 +01:00
# This is later used to check if any options were selected
2023-12-15 13:22:35 +01:00
foreach ( $Param in $SPParams ) {
2024-03-01 13:54:02 +01:00
if ( $global:Params . ContainsKey ( $Param ) ) {
2023-09-27 21:03:25 +02:00
$SPParamCount + +
}
}
2024-06-05 09:17:24 +02:00
# Remove SavedSettings file if it exists and is empty
2024-06-05 19:18:01 +02:00
if ( ( Test-Path " $PSScriptRoot /SavedSettings " ) -and ( [ String ] :: IsNullOrWhiteSpace ( ( Get-content " $PSScriptRoot /SavedSettings " ) ) ) ) {
2024-06-05 09:17:24 +02:00
Remove-Item -Path " $PSScriptRoot /SavedSettings " -recurse
2023-12-15 13:22:35 +01:00
}
2024-03-11 23:38:19 +01:00
# Only run the app selection form if the 'RunAppConfigurator' parameter was passed to the script
2024-03-29 16:56:29 +01:00
if ( $RunAppConfigurator ) {
2024-03-11 23:38:19 +01:00
PrintHeader " App Configurator "
2024-03-29 16:56:29 +01:00
$result = ShowAppSelectionForm
2024-03-11 23:38:19 +01:00
# Show different message based on whether the app selection was saved or cancelled
2024-03-29 16:56:29 +01:00
if ( $result -ne [ System.Windows.Forms.DialogResult ] :: OK ) {
2024-03-11 23:38:19 +01:00
Write-Host " App configurator was closed without saving. " -ForegroundColor Red
}
else {
Write-Output " Your app selection was saved to the 'CustomAppsList' file in the root folder of the script. "
}
2024-04-05 18:26:58 +02:00
AwaitKeyToExit
2024-03-11 23:38:19 +01:00
# Exit script
Exit
}
2023-08-07 00:49:41 +02:00
# Change script execution based on provided parameters or user input
2024-03-01 13:54:02 +01:00
if ( ( -not $global:Params . Count ) -or $RunDefaults -or $RunWin11Defaults -or ( $SPParamCount -eq $global:Params . Count ) ) {
2023-08-03 01:18:02 +02:00
if ( $RunDefaults -or $RunWin11Defaults ) {
2024-04-05 23:35:10 +02:00
$Mode = '1'
2020-11-07 02:57:38 +01:00
}
2023-05-15 16:38:11 -06:00
else {
2023-08-03 22:24:27 +02:00
# Show menu and wait for user input, loops until valid input is provided
2022-09-08 17:20:53 +02:00
Do {
2024-03-29 16:56:29 +01:00
$ModeSelectionMessage = " Please select an option (1/2/3/0) "
PrintHeader 'Menu'
2023-08-03 22:24:27 +02:00
2024-03-29 16:56:29 +01:00
Write-Output " (1) Default Mode: Apply the default settings "
Write-Output " (2) Custom Mode: Modify the script to your needs "
Write-Output " (3) App removal mode: Select & remove apps, without making other changes "
2023-12-15 13:22:35 +01:00
2024-03-29 16:56:29 +01:00
# Only show this option if SavedSettings file exists
if ( Test-Path " $PSScriptRoot /SavedSettings " ) {
Write-Output " (4) Apply saved custom settings from last time "
$ModeSelectionMessage = " Please select an option (1/2/3/4/0) "
2023-08-03 22:24:27 +02:00
}
2023-12-15 13:22:35 +01:00
Write-Output " "
Write-Output " (0) Show information about the script "
Write-Output " "
Write-Output " "
$Mode = Read-Host $ModeSelectionMessage
2020-11-07 02:57:38 +01:00
2023-09-28 16:11:04 +02:00
# Show information based on user input, Suppress user prompt if Silent parameter was passed
2023-05-15 16:38:11 -06:00
if ( $Mode -eq '0' ) {
2023-08-03 22:24:27 +02:00
# Get & print script information from file
2023-12-15 13:22:35 +01:00
PrintFromFile " $PSScriptRoot /Menus/Info "
2023-08-03 22:24:27 +02:00
2024-03-29 16:56:29 +01:00
Write-Output " "
2022-09-08 17:20:53 +02:00
Write-Output " Press any key to go back... "
$null = $Host . UI . RawUI . ReadKey ( " NoEcho,IncludeKeyDown " )
}
2024-03-29 16:56:29 +01:00
elseif ( ( $Mode -eq '4' ) -and -not ( Test-Path " $PSScriptRoot /SavedSettings " ) ) {
2024-04-05 23:35:10 +02:00
$Mode = $null
2023-12-15 13:22:35 +01:00
}
2022-09-08 17:20:53 +02:00
}
2024-03-29 16:56:29 +01:00
while ( $Mode -ne '1' -and $Mode -ne '2' -and $Mode -ne '3' -and $Mode -ne '4' )
2020-11-07 02:57:38 +01:00
}
2020-11-06 12:48:13 +01:00
2022-04-09 18:52:16 +02:00
# Add execution parameters based on the mode
2023-05-15 16:38:11 -06:00
switch ( $Mode ) {
2024-03-29 16:56:29 +01:00
# Default mode, loads defaults after confirmation
2023-05-15 16:38:11 -06:00
'1' {
2024-03-29 16:56:29 +01:00
# Print the default settings & require userconfirmation, unless Silent parameter was passed
if ( -not $Silent ) {
PrintFromFile " $PSScriptRoot /Menus/DefaultSettings "
Write-Output " "
Write-Output " Press enter to execute the script or press CTRL+C to quit... "
Read-Host | Out-Null
}
2023-12-15 13:22:35 +01:00
$DefaultParameterNames = 'RemoveApps' , 'DisableTelemetry' , 'DisableBing' , 'DisableLockscreenTips' , 'DisableSuggestions' , 'ShowKnownFileExt' , 'DisableWidgets' , 'HideChat' , 'DisableCopilot'
2024-03-29 16:56:29 +01:00
PrintHeader 'Default Mode'
2023-09-29 02:39:56 +02:00
# Add default parameters if they don't already exist
foreach ( $ParameterName in $DefaultParameterNames ) {
2024-03-29 16:56:29 +01:00
if ( -not $global:Params . ContainsKey ( $ParameterName ) ) {
2024-03-01 13:54:02 +01:00
$global:Params . Add ( $ParameterName , $true )
2023-09-29 02:39:56 +02:00
}
}
2024-01-31 22:19:50 +01:00
# Only add this option for Windows 10 users, if it doesn't already exist
2024-03-01 13:54:02 +01:00
if ( ( get-ciminstance -query " select caption from win32_operatingsystem where caption like '%Windows 10%' " ) -and ( -not $global:Params . ContainsKey ( 'Hide3dObjects' ) ) ) {
$global:Params . Add ( 'Hide3dObjects' , $Hide3dObjects )
2023-08-03 01:18:02 +02:00
}
2021-12-15 21:45:48 +01:00
}
2022-09-08 17:20:53 +02:00
2024-03-29 16:56:29 +01:00
# Custom mode, show & add options based on user input
2023-08-03 01:18:02 +02:00
'2' {
2023-12-15 13:22:35 +01:00
# Get current Windows build version to compare against features
$WinVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' CurrentBuild
2023-10-31 22:42:13 +01:00
2024-03-29 16:56:29 +01:00
PrintHeader 'Custom Mode'
2020-11-07 02:57:38 +01:00
2023-12-17 21:43:05 +01:00
# Show options for removing apps, only continue on valid input
Do {
Write-Host " Options: " -ForegroundColor Yellow
Write-Host " (n) Don't remove any apps " -ForegroundColor Yellow
Write-Host " (1) Only remove the default selection of bloatware apps from 'Appslist.txt' " -ForegroundColor Yellow
2024-03-04 00:10:24 +01:00
Write-Host " (2) Remove default selection of bloatware apps, aswell as mail & calendar apps, developer apps and gaming apps " -ForegroundColor Yellow
2024-03-11 23:38:19 +01:00
Write-Host " (3) Select which apps to remove and which to keep " -ForegroundColor Yellow
2023-12-17 21:43:05 +01:00
$RemoveCommAppInput = Read-Host " Remove any pre-installed apps? (n/1/2/3) "
2024-03-04 00:10:24 +01:00
# Show app selection form if user entered option 3
if ( $RemoveCommAppInput -eq '3' ) {
$result = ShowAppSelectionForm
2024-03-29 16:56:29 +01:00
if ( $result -ne [ System.Windows.Forms.DialogResult ] :: OK ) {
2024-03-04 00:10:24 +01:00
# User cancelled or closed app selection, show error and change RemoveCommAppInput so the menu will be shown again
Write-Output " "
Write-Host " Cancelled application selection, please try again " -ForegroundColor Red
$RemoveCommAppInput = 'c'
}
Write-Output " "
}
2023-12-17 21:43:05 +01:00
}
while ( $RemoveCommAppInput -ne 'n' -and $RemoveCommAppInput -ne '0' -and $RemoveCommAppInput -ne '1' -and $RemoveCommAppInput -ne '2' -and $RemoveCommAppInput -ne '3' )
2023-08-03 01:18:02 +02:00
2023-12-17 21:43:05 +01:00
# Select correct option based on user input
switch ( $RemoveCommAppInput ) {
'1' {
AddParameter 'RemoveApps' 'Remove default selection of bloatware apps'
}
'2' {
AddParameter 'RemoveApps' 'Remove default selection of bloatware apps'
AddParameter 'RemoveCommApps' 'Remove the Mail, Calender, and People apps'
AddParameter 'RemoveW11Outlook' 'Remove the new Outlook for Windows app'
AddParameter 'RemoveDevApps' 'Remove developer-related apps'
AddParameter 'RemoveGamingApps' 'Remove the Xbox App and Xbox Gamebar'
2024-05-24 14:13:15 +02:00
AddParameter 'DisableDVR' 'Disable Xbox game DVR'
2023-11-19 23:02:54 +01:00
}
2023-12-17 21:43:05 +01:00
'3' {
2024-03-29 16:56:29 +01:00
Write-Output " You have selected $( $global:SelectedApps . Count ) apps for removal "
2024-01-31 22:19:50 +01:00
2024-03-04 12:56:12 +01:00
AddParameter 'RemoveAppsCustom' " Remove $( $global:SelectedApps . Count ) apps: "
2024-05-24 14:13:15 +02:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Disable Xbox game DVR? (y/n) " ) -eq 'y' ) {
AddParameter 'DisableDVR' 'Disable Xbox game DVR'
}
2023-08-03 01:18:02 +02:00
}
2020-11-07 02:57:38 +01:00
}
2024-01-31 22:19:50 +01:00
# Only show this option for Windows 11 users running build 22621 or later
2023-12-15 13:22:35 +01:00
if ( $WinVersion -ge 22621 ) {
2023-10-31 22:42:13 +01:00
Write-Output " "
2023-07-18 00:14:06 +02:00
2023-10-31 18:47:03 +01:00
if ( $ ( Read-Host -Prompt " Remove all pinned apps from the start menu? This applies to all existing and new users and can't be reverted (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'ClearStart' 'Remove all pinned apps from the start menu for new and existing users'
2023-10-31 18:47:03 +01:00
}
}
Write-Output " "
2023-08-07 01:23:55 +02:00
if ( $ ( Read-Host -Prompt " Disable telemetry, diagnostic data, app-launch tracking and targeted ads? (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'DisableTelemetry' 'Disable telemetry, diagnostic data & targeted ads'
2020-11-07 02:57:38 +01:00
}
2023-07-18 00:14:06 +02:00
Write-Output " "
2024-05-24 14:13:15 +02:00
if ( $ ( Read-Host -Prompt " Disable tips, tricks, suggestions and ads in start, settings, notifications, explorer and lockscreen? (y/n) " ) -eq 'y' ) {
AddParameter 'DisableSuggestions' 'Disable tips, tricks, suggestions and ads in start, settings, notifications and Windows explorer'
AddParameter 'DisableLockscreenTips' 'Disable tips & tricks on the lockscreen'
2020-11-07 02:57:38 +01:00
}
2023-07-18 00:14:06 +02:00
Write-Output " "
2024-05-24 14:13:15 +02:00
if ( $ ( Read-Host -Prompt " Disable & remove bing search, bing AI & cortana in Windows search? (y/n) " ) -eq 'y' ) {
AddParameter 'DisableBing' 'Disable & remove bing search, bing AI & cortana in Windows search'
2023-08-03 20:10:24 +02:00
}
2020-11-07 02:57:38 +01:00
2024-01-31 22:19:50 +01:00
# Only show this option for Windows 11 users running build 22621 or later
2023-12-15 13:22:35 +01:00
if ( $WinVersion -ge 22621 ) {
2023-10-31 22:42:13 +01:00
Write-Output " "
2023-07-18 00:14:06 +02:00
2023-10-24 20:39:39 +02:00
if ( $ ( Read-Host -Prompt " Disable Windows Copilot? This applies to all users (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'DisableCopilot' 'Disable Windows copilot'
2023-10-24 20:39:39 +02:00
}
2024-06-05 09:17:24 +02:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Disable Windows Recall snapshots? This applies to all users (y/n) " ) -eq 'y' ) {
AddParameter 'DisableRecall' 'Disable Windows Recall snapshots'
}
2023-10-31 22:42:13 +01:00
}
2023-10-24 20:39:39 +02:00
2024-01-31 22:19:50 +01:00
# Only show this option for Windows 11 users running build 22000 or later
2023-12-15 13:22:35 +01:00
if ( $WinVersion -ge 22000 ) {
2023-10-24 20:39:39 +02:00
Write-Output " "
2023-10-31 18:47:03 +01:00
if ( $ ( Read-Host -Prompt " Restore the old Windows 10 style context menu? (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'RevertContextMenu' 'Restore the old Windows 10 style context menu'
2023-09-08 00:47:59 +02:00
}
}
Write-Output " "
2023-09-27 02:45:34 +02:00
if ( $ ( Read-Host -Prompt " Do you want to make any changes to the taskbar and related services? (y/n) " ) -eq 'y' ) {
2024-01-31 22:19:50 +01:00
# Only show these specific options for Windows 11 users running build 22000 or later
2023-12-15 13:22:35 +01:00
if ( $WinVersion -ge 22000 ) {
2023-07-18 00:14:06 +02:00
Write-Output " "
2023-10-31 18:47:03 +01:00
if ( $ ( Read-Host -Prompt " Align taskbar buttons to the left side? (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'TaskbarAlignLeft' 'Align taskbar icons to the left'
2023-07-18 00:14:06 +02:00
}
2023-08-03 20:10:24 +02:00
2023-08-07 00:49:41 +02:00
# Show options for search icon on taskbar, only continue on valid input
2023-08-03 20:10:24 +02:00
Do {
Write-Output " "
2023-12-17 21:43:05 +01:00
Write-Host " Options: " -ForegroundColor Yellow
Write-Host " (n) No change " -ForegroundColor Yellow
Write-Host " (1) Hide search icon from the taskbar " -ForegroundColor Yellow
Write-Host " (2) Show search icon on the taskbar " -ForegroundColor Yellow
Write-Host " (3) Show search icon with label on the taskbar " -ForegroundColor Yellow
Write-Host " (4) Show search box on the taskbar " -ForegroundColor Yellow
2023-11-19 23:02:54 +01:00
$TbSearchInput = Read-Host " Hide or change the search icon on the taskbar? (n/1/2/3/4) "
2023-08-03 20:10:24 +02:00
}
while ( $TbSearchInput -ne 'n' -and $TbSearchInput -ne '0' -and $TbSearchInput -ne '1' -and $TbSearchInput -ne '2' -and $TbSearchInput -ne '3' -and $TbSearchInput -ne '4' )
# Select correct taskbar search option based on user input
switch ( $TbSearchInput ) {
'1' {
2023-12-15 13:22:35 +01:00
AddParameter 'HideSearchTb' 'Hide search icon from the taskbar'
2023-08-03 20:10:24 +02:00
}
'2' {
2023-12-15 13:22:35 +01:00
AddParameter 'ShowSearchIconTb' 'Show search icon on the taskbar'
2023-08-03 20:10:24 +02:00
}
'3' {
2023-12-15 13:22:35 +01:00
AddParameter 'ShowSearchLabelTb' 'Show search icon with label on the taskbar'
2023-08-03 20:10:24 +02:00
}
'4' {
2023-12-15 13:22:35 +01:00
AddParameter 'ShowSearchBoxTb' 'Show search box on the taskbar'
2023-08-03 20:10:24 +02:00
}
2023-08-07 00:49:41 +02:00
}
Write-Output " "
2023-08-03 20:10:24 +02:00
2023-08-07 00:49:41 +02:00
if ( $ ( Read-Host -Prompt " Hide the taskview button from the taskbar? (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'HideTaskview' 'Hide the taskview button from the taskbar'
2023-08-03 20:10:24 +02:00
}
2022-08-29 19:26:13 +02:00
}
2023-07-18 00:14:06 +02:00
Write-Output " "
2023-10-24 20:39:39 +02:00
if ( $ ( Read-Host -Prompt " Disable the widgets service and hide the icon from the taskbar? (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'DisableWidgets' 'Disable the widget service & hide the widget (news and interests) icon from the taskbar'
2022-08-29 19:26:13 +02:00
}
2024-01-31 22:19:50 +01:00
# Only show this options for Windows users running build 22621 or earlier
2023-12-15 13:22:35 +01:00
if ( $WinVersion -le 22621 ) {
2023-10-31 22:42:13 +01:00
Write-Output " "
2023-07-18 00:14:06 +02:00
2023-10-31 22:42:13 +01:00
if ( $ ( Read-Host -Prompt " Hide the chat (meet now) icon from the taskbar? (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'HideChat' 'Hide the chat (meet now) icon from the taskbar'
2023-10-31 22:42:13 +01:00
}
2022-08-29 16:14:36 +02:00
}
2023-07-18 00:14:06 +02:00
}
2023-08-03 22:24:27 +02:00
Write-Output " "
2024-01-31 22:19:50 +01:00
if ( $ ( Read-Host -Prompt " Do you want to make any changes to Windows explorer? (y/n) " ) -eq 'y' ) {
2023-08-03 20:10:24 +02:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Show hidden files, folders and drives? (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'ShowHiddenFolders' 'Show hidden files, folders and drives'
2023-08-03 20:10:24 +02:00
}
2023-08-03 22:24:27 +02:00
Write-Output " "
2023-08-03 20:10:24 +02:00
if ( $ ( Read-Host -Prompt " Show file extensions for known file types? (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'ShowKnownFileExt' 'Show file extensions for known file types'
2023-08-03 20:10:24 +02:00
}
2023-10-15 19:48:27 +02:00
Write-Output " "
2024-01-31 22:19:50 +01:00
if ( $ ( Read-Host -Prompt " Hide duplicate removable drive entries from the Windows explorer sidepane so they only show under This PC? (y/n) " ) -eq 'y' ) {
AddParameter 'HideDupliDrive' 'Hide duplicate removable drive entries from the Windows explorer navigation pane'
2023-10-15 19:48:27 +02:00
}
2023-07-18 00:14:06 +02:00
2024-01-31 22:19:50 +01:00
# Only show option for disabling these specific folders for Windows 10 users
2023-10-24 20:39:39 +02:00
if ( get-ciminstance -query " select caption from win32_operatingsystem where caption like '%Windows 10%' " ) {
2023-07-18 00:14:06 +02:00
Write-Output " "
2024-01-31 22:19:50 +01:00
if ( $ ( Read-Host -Prompt " Do you want to hide any folders from the Windows explorer sidepane? (y/n) " ) -eq 'y' ) {
2023-10-24 20:39:39 +02:00
Write-Output " "
2023-07-18 00:14:06 +02:00
2024-01-31 22:19:50 +01:00
if ( $ ( Read-Host -Prompt " Hide the onedrive folder from the Windows explorer sidepane? (y/n) " ) -eq 'y' ) {
AddParameter 'HideOnedrive' 'Hide the onedrive folder in the Windows explorer sidepanel'
2023-10-24 20:39:39 +02:00
}
2022-08-29 16:14:36 +02:00
2023-10-24 20:39:39 +02:00
Write-Output " "
2024-01-31 22:19:50 +01:00
if ( $ ( Read-Host -Prompt " Hide the 3D objects folder from the Windows explorer sidepane? (y/n) " ) -eq 'y' ) {
AddParameter 'Hide3dObjects' " Hide the 3D objects folder under 'This pc' in Windows explorer "
2023-10-24 20:39:39 +02:00
}
Write-Output " "
2024-01-31 22:19:50 +01:00
if ( $ ( Read-Host -Prompt " Hide the music folder from the Windows explorer sidepane? (y/n) " ) -eq 'y' ) {
AddParameter 'HideMusic' " Hide the music folder under 'This pc' in Windows explorer "
2023-10-24 20:39:39 +02:00
}
2023-06-01 11:49:16 +02:00
}
2022-08-29 16:14:36 +02:00
}
2020-11-07 02:57:38 +01:00
}
2024-03-06 19:15:23 +01:00
# Only show option for disabling context menu items for Windows 10 users or if the user opted to restore the Windows 10 context menu
if ( ( get-ciminstance -query " select caption from win32_operatingsystem where caption like '%Windows 10%' " ) -or $global:Params . ContainsKey ( 'RevertContextMenu' ) ) {
2023-07-18 00:14:06 +02:00
Write-Output " "
2023-06-01 11:49:16 +02:00
if ( $ ( Read-Host -Prompt " Do you want to disable any context menu options? (y/n) " ) -eq 'y' ) {
2023-07-18 00:14:06 +02:00
Write-Output " "
2023-07-27 01:09:58 +02:00
if ( $ ( Read-Host -Prompt " Hide the 'Include in library' option in the context menu? (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'HideIncludeInLibrary' " Hide the 'Include in library' option in the context menu "
2023-06-01 11:49:16 +02:00
}
2022-08-29 16:14:36 +02:00
2023-07-18 00:14:06 +02:00
Write-Output " "
2023-07-27 01:09:58 +02:00
if ( $ ( Read-Host -Prompt " Hide the 'Give access to' option in the context menu? (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'HideGiveAccessTo' " Hide the 'Give access to' option in the context menu "
2023-06-01 11:49:16 +02:00
}
2022-08-29 16:14:36 +02:00
2023-07-18 00:14:06 +02:00
Write-Output " "
2023-07-27 01:09:58 +02:00
if ( $ ( Read-Host -Prompt " Hide the 'Share' option in the context menu? (y/n) " ) -eq 'y' ) {
2023-12-15 13:22:35 +01:00
AddParameter 'HideShare' " Hide the 'Share' option in the context menu "
2023-06-01 11:49:16 +02:00
}
2022-08-29 16:14:36 +02:00
}
2020-11-07 02:57:38 +01:00
}
2023-09-28 16:11:04 +02:00
# Suppress prompt if Silent parameter was passed
2023-09-29 02:39:56 +02:00
if ( -not $Silent ) {
2023-09-28 16:11:04 +02:00
Write-Output " "
Write-Output " "
Write-Output " "
2024-03-04 12:56:12 +01:00
Write-Output " Press enter to confirm your choices and execute the script or press CTRL+C to quit... "
Read-Host | Out-Null
2023-09-28 16:11:04 +02:00
}
2023-09-27 21:03:25 +02:00
2024-03-29 16:56:29 +01:00
PrintHeader 'Custom Mode'
2023-12-15 13:22:35 +01:00
}
2024-03-29 16:56:29 +01:00
# App removal, remove apps based on user selection
2023-12-15 13:22:35 +01:00
'3' {
2024-03-29 16:56:29 +01:00
PrintHeader " App Removal "
$result = ShowAppSelectionForm
if ( $result -eq [ System.Windows.Forms.DialogResult ] :: OK ) {
Write-Output " You have selected $( $global:SelectedApps . Count ) apps for removal "
AddParameter 'RemoveAppsCustom' " Remove $( $global:SelectedApps . Count ) apps: "
# Suppress prompt if Silent parameter was passed
if ( -not $Silent ) {
Write-Output " "
Write-Output " Press enter to remove the selected apps or press CTRL+C to quit... "
Read-Host | Out-Null
}
}
else {
Write-Host " Selection was cancelled, no apps have been removed! " -ForegroundColor Red
}
Write-Output " "
}
# Load custom options selection from the "SavedSettings" file
'4' {
if ( -not $Silent ) {
PrintHeader 'Custom Mode'
Write-Output " Win11Debloat will make the following changes: "
# Get & print default settings info from file
Foreach ( $line in ( Get-Content -Path " $PSScriptRoot /SavedSettings " ) ) {
# Remove any spaces before and after the Appname
$line = $line . Trim ( )
# Check if line has # char, show description, add parameter
if ( -not ( $line . IndexOf ( '#' ) -eq -1 ) ) {
Write-Output $line . Substring ( ( $line . IndexOf ( '#' ) + 1 ) , ( $line . Length - $line . IndexOf ( '#' ) - 1 ) )
$paramName = $line . Substring ( 0 , $line . IndexOf ( '#' ) )
if ( $paramName -eq " RemoveAppsCustom " ) {
# If paramName is RemoveAppsCustom, check if CustomAppsFile exists
if ( Test-Path " $PSScriptRoot /CustomAppsList " ) {
# Apps file exists, print list of apps
$appsList = @ ( )
# Get apps list from file
Foreach ( $app in ( Get-Content -Path " $PSScriptRoot /CustomAppsList " ) ) {
# Remove any spaces before and after the app name
$app = $app . Trim ( )
$appsList + = $app
}
Write-Host $appsList -ForegroundColor DarkGray
}
else {
# Apps file does not exist, print error and continue to next item
2024-05-14 23:56:58 +02:00
Write-Host " Error: Could not load custom apps list from file, no apps will be removed! " -ForegroundColor Red
2024-03-29 16:56:29 +01:00
continue
}
}
if ( -not $global:Params . ContainsKey ( $ParameterName ) ) {
$global:Params . Add ( $paramName , $true )
}
}
}
Write-Output " "
Write-Output " "
Write-Output " Press enter to execute the script or press CTRL+C to quit... "
Read-Host | Out-Null
}
PrintHeader 'Custom Mode'
2020-11-07 02:57:38 +01:00
}
}
2020-11-06 12:48:13 +01:00
}
2023-05-15 16:38:11 -06:00
else {
2024-03-29 16:56:29 +01:00
PrintHeader 'Custom Mode'
2020-11-06 12:48:13 +01:00
}
2023-08-03 22:24:27 +02:00
2024-03-01 13:54:02 +01:00
# If the number of keys in SPParams equals the number of keys in Params then no modifications/changes were selected
# or added by the user, and the script can exit without making any changes.
if ( $SPParamCount -eq $global:Params . Keys . Count ) {
2023-09-28 16:11:04 +02:00
Write-Output " The script completed without making any changes. "
2024-04-05 18:26:58 +02:00
AwaitKeyToExit
2020-10-27 23:26:39 +01:00
}
2023-09-28 16:11:04 +02:00
else {
# Execute all selected/provided parameters
2024-03-01 13:54:02 +01:00
switch ( $global:Params . Keys ) {
2023-09-28 16:11:04 +02:00
'RemoveApps' {
2024-03-29 16:56:29 +01:00
RemoveAppsFromFile " $PSScriptRoot /Appslist.txt "
2023-11-19 23:02:54 +01:00
continue
}
2024-03-04 00:10:24 +01:00
'RemoveAppsCustom' {
2024-03-04 12:56:12 +01:00
if ( Test-Path " $PSScriptRoot /CustomAppsList " ) {
$appsList = @ ( )
2024-03-04 00:10:24 +01:00
# Get apps list from file
2024-03-04 12:56:12 +01:00
Foreach ( $app in ( Get-Content -Path " $PSScriptRoot /CustomAppsList " ) ) {
2024-03-04 00:10:24 +01:00
# Remove any spaces before and after the app name
2024-03-04 12:56:12 +01:00
$app = $app . Trim ( )
2024-03-04 00:10:24 +01:00
2024-03-04 12:56:12 +01:00
$appsList + = $app
2024-03-04 00:10:24 +01:00
}
2024-03-04 12:56:12 +01:00
Write-Output " > Removing $( $appsList . Count ) apps... "
2024-03-29 16:56:29 +01:00
RemoveApps $appsList
2024-03-04 00:10:24 +01:00
}
else {
2024-03-11 23:38:19 +01:00
Write-Host " > Could not load custom apps list from file, no apps were removed! " -ForegroundColor Red
2024-03-04 00:10:24 +01:00
}
Write-Output " "
continue
}
2023-11-19 23:02:54 +01:00
'RemoveCommApps' {
Write-Output " > Removing Mail, Calendar and People apps... "
2023-11-19 23:40:35 +01:00
2024-03-04 12:56:12 +01:00
$appsList = 'Microsoft.windowscommunicationsapps' , 'Microsoft.People'
2024-03-29 16:56:29 +01:00
RemoveApps $appsList
2023-11-19 23:02:54 +01:00
Write-Output " "
continue
}
'RemoveW11Outlook' {
Write-Output " > Removing new Outlook for Windows app... "
2023-11-19 23:40:35 +01:00
2024-03-04 12:56:12 +01:00
$appsList = 'Microsoft.OutlookForWindows'
2024-03-29 16:56:29 +01:00
RemoveApps $appsList
2023-11-19 23:02:54 +01:00
Write-Output " "
2023-09-28 16:11:04 +02:00
continue
}
2023-12-17 21:43:05 +01:00
'RemoveDevApps' {
Write-Output " > Removing developer-related related apps... "
2024-03-04 12:56:12 +01:00
$appsList = 'Microsoft.PowerAutomateDesktop' , 'Microsoft.RemoteDesktop' , 'Windows.DevHome'
2024-03-29 16:56:29 +01:00
RemoveApps $appsList
2023-12-17 21:43:05 +01:00
Write-Output " "
continue
}
2023-09-28 16:11:04 +02:00
'RemoveGamingApps' {
2023-12-15 13:22:35 +01:00
Write-Output " > Removing gaming related apps... "
2024-03-04 12:56:12 +01:00
$appsList = 'Microsoft.GamingApp' , 'Microsoft.XboxGameOverlay' , 'Microsoft.XboxGamingOverlay'
2024-03-29 16:56:29 +01:00
RemoveApps $appsList
2023-12-15 13:22:35 +01:00
Write-Output " "
2023-09-28 16:11:04 +02:00
continue
}
2024-05-24 14:13:15 +02:00
'DisableDVR' {
RegImport " > Disabling Xbox game DVR... " $PSScriptRoot \ Regfiles \ Disable_DVR . reg
continue
}
2023-10-31 18:47:03 +01:00
'ClearStart' {
ClearStartMenu " > Removing all pinned apps from the start menu... "
continue
}
2023-09-28 16:11:04 +02:00
'DisableTelemetry' {
RegImport " > Disabling telemetry, diagnostic data, app-launch tracking and targeted ads... " $PSScriptRoot \ Regfiles \ Disable_Telemetry . reg
continue
}
{ $_ -in " DisableBingSearches " , " DisableBing " } {
2024-03-01 13:54:02 +01:00
RegImport " > Disabling bing search, bing AI & cortana in Windows search... " $PSScriptRoot \ Regfiles \ Disable_Bing_Cortana_In_Search . reg
# Also remove the app package for bing search
2024-03-04 12:56:12 +01:00
$appsList = 'Microsoft.BingSearch'
2024-03-29 16:56:29 +01:00
RemoveApps $appsList
2024-02-23 12:25:11 +01:00
2024-03-01 13:54:02 +01:00
Write-Output " "
2023-09-28 16:11:04 +02:00
continue
}
2023-12-17 21:43:05 +01:00
{ $_ -in " DisableLockscrTips " , " DisableLockscreenTips " } {
2023-09-28 16:11:04 +02:00
RegImport " > Disabling tips & tricks on the lockscreen... " $PSScriptRoot \ Regfiles \ Disable_Lockscreen_Tips . reg
continue
}
{ $_ -in " DisableSuggestions " , " DisableWindowsSuggestions " } {
RegImport " > Disabling tips, tricks, suggestions and ads across Windows... " $PSScriptRoot \ Regfiles \ Disable_Windows_Suggestions . reg
continue
}
2023-10-31 18:47:03 +01:00
'RevertContextMenu' {
RegImport " > Restoring the old Windows 10 style context menu... " $PSScriptRoot \ Regfiles \ Disable_Show_More_Options_Context_Menu . reg
continue
}
2023-09-28 16:11:04 +02:00
'TaskbarAlignLeft' {
RegImport " > Aligning taskbar buttons to the left... " $PSScriptRoot \ Regfiles \ Align_Taskbar_Left . reg
continue
}
'HideSearchTb' {
RegImport " > Hiding the search icon from the taskbar... " $PSScriptRoot \ Regfiles \ Hide_Search_Taskbar . reg
continue
}
'ShowSearchIconTb' {
RegImport " > Changing taskbar search to icon only... " $PSScriptRoot \ Regfiles \ Show_Search_Icon . reg
continue
}
'ShowSearchLabelTb' {
RegImport " > Changing taskbar search to icon with label... " $PSScriptRoot \ Regfiles \ Show_Search_Icon_And_Label . reg
continue
}
'ShowSearchBoxTb' {
RegImport " > Changing taskbar search to search box... " $PSScriptRoot \ Regfiles \ Show_Search_Box . reg
continue
}
'HideTaskview' {
RegImport " > Hiding the taskview button from the taskbar... " $PSScriptRoot \ Regfiles \ Hide_Taskview_Taskbar . reg
continue
}
'DisableCopilot' {
RegImport " > Disabling Windows copilot... " $PSScriptRoot \ Regfiles \ Disable_Copilot . reg
continue
}
2024-06-05 09:17:24 +02:00
'DisableRecall' {
RegImport " > Disabling Windows Recall snapshots... " $PSScriptRoot \ Regfiles \ Disable_AI_Recall . reg
continue
}
2023-09-28 16:11:04 +02:00
{ $_ -in " HideWidgets " , " DisableWidgets " } {
RegImport " > Disabling the widget service and hiding the widget icon from the taskbar... " $PSScriptRoot \ Regfiles \ Disable_Widgets_Taskbar . reg
continue
}
{ $_ -in " HideChat " , " DisableChat " } {
RegImport " > Hiding the chat icon from the taskbar... " $PSScriptRoot \ Regfiles \ Disable_Chat_Taskbar . reg
continue
}
'ShowHiddenFolders' {
RegImport " > Unhiding hidden files, folders and drives... " $PSScriptRoot \ Regfiles \ Show_Hidden_Folders . reg
continue
}
'ShowKnownFileExt' {
RegImport " > Enabling file extensions for known file types... " $PSScriptRoot \ Regfiles \ Show_Extensions_For_Known_File_Types . reg
2023-10-15 19:48:27 +02:00
continue
}
'HideDupliDrive' {
2024-01-31 22:19:50 +01:00
RegImport " > Hiding duplicate removable drive entries from the Windows explorer navigation pane... " $PSScriptRoot \ Regfiles \ Hide_duplicate_removable_drives_from_navigation_pane_of_File_Explorer . reg
2023-09-28 16:11:04 +02:00
continue
}
{ $_ -in " HideOnedrive " , " DisableOnedrive " } {
2024-01-31 22:19:50 +01:00
RegImport " > Hiding the onedrive folder from the Windows explorer navigation pane... " $PSScriptRoot \ Regfiles \ Hide_Onedrive_Folder . reg
2023-09-28 16:11:04 +02:00
continue
}
{ $_ -in " Hide3dObjects " , " Disable3dObjects " } {
2024-01-31 22:19:50 +01:00
RegImport " > Hiding the 3D objects folder from the Windows explorer navigation pane... " $PSScriptRoot \ Regfiles \ Hide_3D_Objects_Folder . reg
2023-09-28 16:11:04 +02:00
continue
}
{ $_ -in " HideMusic " , " DisableMusic " } {
2024-01-31 22:19:50 +01:00
RegImport " > Hiding the music folder from the Windows explorer navigation pane... " $PSScriptRoot \ Regfiles \ Hide_Music_folder . reg
2023-09-28 16:11:04 +02:00
continue
}
{ $_ -in " HideIncludeInLibrary " , " DisableIncludeInLibrary " } {
RegImport " > Hiding 'Include in library' in the context menu... " $PSScriptRoot \ Regfiles \ Disable_Include_in_library_from_context_menu . reg
continue
}
{ $_ -in " HideGiveAccessTo " , " DisableGiveAccessTo " } {
RegImport " > Hiding 'Give access to' in the context menu... " $PSScriptRoot \ Regfiles \ Disable_Give_access_to_context_menu . reg
continue
}
{ $_ -in " HideShare " , " DisableShare " } {
RegImport " > Hiding 'Share' in the context menu... " $PSScriptRoot \ Regfiles \ Disable_Share_from_context_menu . reg
continue
}
}
2020-10-27 23:26:39 +01:00
2023-09-28 16:11:04 +02:00
RestartExplorer
2023-09-27 21:03:25 +02:00
2024-06-05 19:53:59 +02:00
Write-Output " "
2023-09-27 21:03:25 +02:00
Write-Output " "
2023-09-28 16:11:04 +02:00
Write-Output " "
Write-Output " Script completed successfully! "
2023-09-27 21:03:25 +02:00
2024-04-05 18:26:58 +02:00
AwaitKeyToExit
2023-09-28 16:11:04 +02:00
}