From 01770eb21d04dfca9007e9aadf751d3d87584132 Mon Sep 17 00:00:00 2001 From: Richard Newton Date: Fri, 19 Mar 2021 20:16:00 -0400 Subject: [PATCH] Fixed CustomList not saving The customlist was not saving as explained in issue #345. The issue was that on lines 529 and 537 it was set as $CustomizeForm.Controls when it should have instead been $ListPanel.Controls. Verified that the fix works. --- Windows10DebloaterGUI.ps1 | 106 ++++++++++++++------------------------ 1 file changed, 40 insertions(+), 66 deletions(-) diff --git a/Windows10DebloaterGUI.ps1 b/Windows10DebloaterGUI.ps1 index 85a0962..db861d4 100644 --- a/Windows10DebloaterGUI.ps1 +++ b/Windows10DebloaterGUI.ps1 @@ -35,7 +35,6 @@ If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]: } } - #Unnecessary Windows 10 AppX apps that will be removed by the blacklist. $global:Bloatware = @( "Microsoft.PPIProjection" @@ -218,7 +217,7 @@ $Form.FormBorderStyle = 'FixedSingle' $Form.MinimizeBox = $false $Form.MaximizeBox = $false $Form.ShowIcon = $false -$Form.text = "Windows10Debloater" +$Form.text = "Windows10Debloader" $Form.TopMost = $false $Form.BackColor = [System.Drawing.ColorTranslator]::FromHtml("#252525") @@ -270,7 +269,7 @@ $Debloat.ForeColor = [System.Drawing.ColorTranslator]::FromHtml("# $CustomizeBlacklist = New-Object system.Windows.Forms.Button $CustomizeBlacklist.FlatStyle = 'Flat' -$CustomizeBlacklist.text = "CUSTOMISE BLOCKLIST" +$CustomizeBlacklist.text = "CUSTOMISE BLACKLIST" $CustomizeBlacklist.width = 460 $CustomizeBlacklist.height = 30 $CustomizeBlacklist.Anchor = 'top,right,left' @@ -290,7 +289,7 @@ $RemoveAllBloatware.ForeColor = [System.Drawing.ColorTranslator]::FromHtml("# $RemoveBlacklistedBloatware = New-Object system.Windows.Forms.Button $RemoveBlacklistedBloatware.FlatStyle = 'Flat' -$RemoveBlacklistedBloatware.text = "REMOVE BLOATWARE WITH CUSTOM BLOCKLIST" +$RemoveBlacklistedBloatware.text = "REMOVE BLOATWARE WITH CUSTOM BLACKLIST" $RemoveBlacklistedBloatware.width = 460 $RemoveBlacklistedBloatware.height = 30 $RemoveBlacklistedBloatware.Anchor = 'top,right,left' @@ -489,10 +488,6 @@ Else { Start-Transcript -OutputDirectory "${DebloatFolder}" -Write-Output "Creating System Restore Point if one does not already exist. If one does, then you will receive a warning. Please wait..." -Checkpoint-Computer -Description "Before using W10DebloaterGUI.ps1" - - #region gui events { $CustomizeBlacklist.Add_Click( { $CustomizeForm = New-Object System.Windows.Forms.Form @@ -502,7 +497,7 @@ $CustomizeBlacklist.Add_Click( { $CustomizeForm.MinimizeBox = $false $CustomizeForm.MaximizeBox = $false $CustomizeForm.ShowIcon = $false - $CustomizeForm.Text = "Customize Allowlist and Blocklist" + $CustomizeForm.Text = "Customize Whitelist and Blacklist" $CustomizeForm.TopMost = $false $CustomizeForm.AutoScroll = $false $CustomizeForm.BackColor = [System.Drawing.ColorTranslator]::FromHtml("#252525") @@ -518,7 +513,7 @@ $CustomizeBlacklist.Add_Click( { $SaveList = New-Object System.Windows.Forms.Button $SaveList.FlatStyle = 'Flat' - $SaveList.Text = "Save custom Allowlist and Blocklist to custom-lists.ps1" + $SaveList.Text = "Save custom Whitelist and Blacklist to custom-lists.ps1" $SaveList.width = 480 $SaveList.height = 30 $SaveList.Location = New-Object System.Drawing.Point(10, 530) @@ -531,7 +526,7 @@ $CustomizeBlacklist.Add_Click( { $ErrorActionPreference = 'SilentlyContinue' '$global:WhiteListedApps = @(' | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Encoding utf8 - @($CustomizeForm.controls) | ForEach { + @($ListPanel.controls) | ForEach { if ($_ -is [System.Windows.Forms.CheckBox] -and $_.Enabled -and !$_.Checked) { " ""$( $_.Text )""" | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8 } @@ -539,7 +534,7 @@ $CustomizeBlacklist.Add_Click( { ')' | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8 '$global:Bloatware = @(' | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8 - @($CustomizeForm.controls) | ForEach { + @($ListPanel.controls) | ForEach { if ($_ -is [System.Windows.Forms.CheckBox] -and $_.Enabled -and $_.Checked) { " ""$($_.Text)""" | Out-File -FilePath $PSScriptRoot\custom-lists.ps1 -Append -Encoding utf8 } @@ -675,7 +670,7 @@ $RemoveBlacklistedBloatware.Add_Click( { Write-Host "...and the final cleanup..." Get-AppxPackage -AllUsers | Where-Object Name -cmatch $global:BloatwareRegex | Remove-AppxPackage } - Write-Host "`n`n`n`n`n`n`n`n`n`n`n`n`n`n`n`n`nRemoving blocklisted Bloatware.`n" + Write-Host "`n`n`n`n`n`n`n`n`n`n`n`n`n`n`n`n`nRemoving blacklisted Bloatware.`n" DebloatBlacklist Write-Host "Bloatware removed!" }) @@ -873,64 +868,43 @@ $RemoveAllBloatware.Add_Click( { } Function UnpinStart { - # https://superuser.com/a/1442733 - # Requires -RunAsAdministrator - -$START_MENU_LAYOUT = @" - - - - - - - - -"@ - - $layoutFile="C:\Windows\StartMenuLayout.xml" - - #Delete layout file if it already exists - If(Test-Path $layoutFile) - { - Remove-Item $layoutFile - } - - #Creates the blank layout file - $START_MENU_LAYOUT | Out-File $layoutFile -Encoding ASCII - - $regAliases = @("HKLM", "HKCU") + #Credit to Vikingat-Rage + #https://superuser.com/questions/1068382/how-to-remove-all-the-tiles-in-the-windows-10-start-menu + #Unpins all tiles from the Start Menu + Write-Host "Unpinning all tiles from the start menu" + (New-Object -Com Shell.Application). + NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}'). + Items() | + % { $_.Verbs() } | + ? { $_.Name -match 'Un.*pin from Start' } | + % { $_.DoIt() } + } - #Assign the start layout and force it to apply with "LockedStartLayout" at both the machine and user level - foreach ($regAlias in $regAliases){ - $basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows" - $keyPath = $basePath + "\Explorer" - IF(!(Test-Path -Path $keyPath)) { - New-Item -Path $basePath -Name "Explorer" - } - Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 1 - Set-ItemProperty -Path $keyPath -Name "StartLayoutFile" -Value $layoutFile + Function Remove3dObjects { + #Removes 3D Objects from the 'My Computer' submenu in explorer + Write-Output "Removing 3D Objects from explorer 'My Computer' submenu" + $Objects32 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" + $Objects64 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" + If (Test-Path $Objects32) { + Remove-Item $Objects32 -Recurse } - - #Restart Explorer, open the start menu (necessary to load the new layout), and give it a few seconds to process - Stop-Process -name explorer - Start-Sleep -s 5 - $wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{ESCAPE}') - Start-Sleep -s 5 - - #Enable the ability to pin items again by disabling "LockedStartLayout" - foreach ($regAlias in $regAliases){ - $basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows" - $keyPath = $basePath + "\Explorer" - Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 0 + If (Test-Path $Objects64) { + Remove-Item $Objects64 -Recurse } + } - #Restart Explorer and delete the layout file - Stop-Process -name explorer + + Function CheckDMWService { - # Uncomment the next line to make clean start menu default for all new users - #Import-StartLayout -LayoutPath $layoutFile -MountPath $env:SystemDrive\ + Param([switch]$Debloat) + + If (Get-Service dmwappushservice | Where-Object { $_.StartType -eq "Disabled" }) { + Set-Service dmwappushservice -StartupType Automatic + } - Remove-Item $layoutFile + If (Get-Service dmwappushservice | Where-Object { $_.Status -eq "Stopped" }) { + Start-Service dmwappushservice + } } Function CheckInstallService { @@ -947,7 +921,7 @@ $START_MENU_LAYOUT = @" DebloatAll Write-Host "Removing leftover bloatware registry keys." Remove-Keys - Write-Host "Checking to see if any Allowlisted Apps were removed, and if so re-adding them." + Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them." FixWhitelistedApps Write-Host "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning." Protect-Privacy