diff --git a/config/tweaks.json b/config/tweaks.json index 526484db..d303f5ef 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -34,7 +34,7 @@ "Description": "Hibernation is really meant for laptops as it saves what's in memory before turning the pc off. It really should never be used, but some people are lazy and rely on it. Don't be like Bob. Bob likes hibernation.", "category": "Essential Tweaks", "panel": "1", - "Order": "a011_", + "Order": "a012_", "registry": [ { "Path": "HKLM:\\System\\CurrentControlSet\\Control\\Session Manager\\Power", @@ -63,7 +63,7 @@ "Description": "Disables HomeGroup - HomeGroup is a password-protected home networking service that lets you share your stuff with other PCs that are currently running and connected to your network.", "category": "Essential Tweaks", "panel": "1", - "Order": "a009_", + "Order": "a011_", "service": [ { "Name": "HomeGroupListener", @@ -77,9 +77,9 @@ } ] }, - "WPFTweaksAdobe": { + "WPFTweaksDebloatAdobe": { "Content": "Debloat Adobe", - "Description": "Sets Adobe Services to Manual & disable acrobat auto-updates", + "Description": "Manages Adobe Services, Adobe Desktop Service, and Acrobat Updates", "category": "Essential Tweaks", "panel": "1", "Order": "a009_", @@ -87,13 +87,20 @@ " function CCStopper { $path = \"C:\\Program Files (x86)\\Common Files\\Adobe\\Adobe Desktop Common\\ADS\\Adobe Desktop Service.exe\" - Takeown /f $path - $acl = Get-Acl $path - $acl.SetOwner([System.Security.Principal.NTAccount]\"Administrators\") - $acl | Set-Acl $path + + # Test if the path exists before proceeding + if (Test-Path $path) { + Takeown /f $path + $acl = Get-Acl $path + $acl.SetOwner([System.Security.Principal.NTAccount]\"Administrators\") + $acl | Set-Acl $path - Rename-Item -Path $path -NewName \"Adobe Desktop Service.exe.old\" -Force + Rename-Item -Path $path -NewName \"Adobe Desktop Service.exe.old\" -Force + } else { + Write-Host \"Adobe Desktop Service is not in the default location.\" + } } + function AcrobatUpdates { # Editing Acrobat Updates. The last folder before the key is dynamic, therefore using a script. @@ -113,7 +120,8 @@ # Get the full registry path $fullPath = Join-Path -Path $rootPath -ChildPath $subKey.PSChildName try { - Set-ItemProperty -Path $fullPath -Name Mode -Value 4 + Set-ItemProperty -Path $fullPath -Name Mode -Value 0 + Write-Host \"Acrobat Updates have been disabled.\" } catch { Write-Host \"Registry Key for changing Acrobat Updates does not exist in $fullPath\" } @@ -216,6 +224,119 @@ } ] }, + "WPFTweaksBlockAdobeNet": { + "Content": "Block Adobe Networking", + "Description": "Reduce user interruptions by selectively blocking connections to Adobe's activation and telemetry servers. ", + "category": "Essential Tweaks", + "panel": "1", + "Order": "a010_", + "InvokeScript": [ + " + # Define the URL of the remote HOSTS file and the local paths + $remoteHostsUrl = \"https://raw.githubusercontent.com/Ruddernation-Designs/Adobe-URL-Block-List/master/hosts\" + $localHostsPath = \"C:\\Windows\\System32\\drivers\\etc\\hosts\" + $tempHostsPath = \"C:\\Windows\\System32\\drivers\\etc\\temp_hosts\" + + # Download the remote HOSTS file to a temporary location + try { + Invoke-WebRequest -Uri $remoteHostsUrl -OutFile $tempHostsPath + Write-Output \"Downloaded the remote HOSTS file to a temporary location.\" + } + catch { + Write-Error \"Failed to download the HOSTS file. Error: $_\" + } + + # Check if the AdobeNetBlock has already been started + try { + $localHostsContent = Get-Content $localHostsPath -ErrorAction Stop + + # Check if AdobeNetBlock markers exist + $blockStartExists = $localHostsContent -like \"*#AdobeNetBlock-start*\" + if ($blockStartExists) { + Write-Output \"AdobeNetBlock-start already exists. Skipping addition of new block.\" + } else { + # Load the new block from the downloaded file + $newBlockContent = Get-Content $tempHostsPath -ErrorAction Stop + $newBlockContent = $newBlockContent | Where-Object { $_ -notmatch \"^\\s*#\" -and $_ -ne \"\" } # Exclude empty lines and comments + $newBlockHeader = \"#AdobeNetBlock-start\" + $newBlockFooter = \"#AdobeNetBlock-end\" + + # Combine the contents, ensuring new block is properly formatted + $combinedContent = $localHostsContent + $newBlockHeader, $newBlockContent, $newBlockFooter | Out-String + + # Write the combined content back to the original HOSTS file + $combinedContent | Set-Content $localHostsPath -Encoding ASCII + Write-Output \"Successfully added the AdobeNetBlock.\" + } + } + catch { + Write-Error \"Error during processing: $_\" + } + + # Clean up temporary file + Remove-Item $tempHostsPath -ErrorAction Ignore + + # Flush the DNS resolver cache + try { + Invoke-Expression \"ipconfig /flushdns\" + Write-Output \"DNS cache flushed successfully.\" + } + catch { + Write-Error \"Failed to flush DNS cache. Error: $_\" + } + " + ], + "UndoScript": [ + " + # Define the local path of the HOSTS file + $localHostsPath = \"C:\\Windows\\System32\\drivers\\etc\\hosts\" + + # Load the content of the HOSTS file + try { + $hostsContent = Get-Content $localHostsPath -ErrorAction Stop + } + catch { + Write-Error \"Failed to load the HOSTS file. Error: $_\" + return + } + + # Initialize flags and buffer for new content + $recording = $true + $newContent = @() + + # Iterate over each line of the HOSTS file + foreach ($line in $hostsContent) { + if ($line -match \"#AdobeNetBlock-start\") { + $recording = $false + } + if ($recording) { + $newContent += $line + } + if ($line -match \"#AdobeNetBlock-end\") { + $recording = $true + } + } + + # Write the filtered content back to the HOSTS file + try { + $newContent | Set-Content $localHostsPath -Encoding ASCII + Write-Output \"Successfully removed the AdobeNetBlock section from the HOSTS file.\" + } + catch { + Write-Error \"Failed to write back to the HOSTS file. Error: $_\" + } + + # Flush the DNS resolver cache + try { + Invoke-Expression \"ipconfig /flushdns\" + Write-Output \"DNS cache flushed successfully.\" + } + catch { + Write-Error \"Failed to flush DNS cache. Error: $_\" + } + " + ] + }, "WPFTweaksLoc": { "Content": "Disable Location Tracking", "Description": "Disables Location Tracking...DUH!", diff --git a/functions/private/Get-WinUtilCheckBoxes.ps1 b/functions/private/Get-WinUtilCheckBoxes.ps1 index 2096d1fc..8a13761f 100644 --- a/functions/private/Get-WinUtilCheckBoxes.ps1 +++ b/functions/private/Get-WinUtilCheckBoxes.ps1 @@ -5,9 +5,6 @@ Function Get-WinUtilCheckBoxes { .SYNOPSIS Finds all checkboxes that are checked on the specific tab and inputs them into a script. - .PARAMETER Group - The group of checkboxes to check - .PARAMETER unCheck Whether to uncheck the checkboxes that are checked. Defaults to true @@ -32,7 +29,20 @@ Function Get-WinUtilCheckBoxes { $CheckBoxes = $sync.GetEnumerator() | Where-Object { $_.Value -is [System.Windows.Controls.CheckBox] } + # First check and add WPFTweaksRestorePoint if checked + $RestorePoint = $CheckBoxes | Where-Object { $_.Key -eq 'WPFTweaksRestorePoint' -and $_.Value.IsChecked -eq $true } + if ($RestorePoint) { + $Output["WPFTweaks"] = @('WPFTweaksRestorePoint') + Write-Debug "Adding WPFTweaksRestorePoint as first in WPFTweaks" + + if ($unCheck) { + $RestorePoint.Value.IsChecked = $false + } + } + foreach ($CheckBox in $CheckBoxes) { + if ($CheckBox.Key -eq 'WPFTweaksRestorePoint') { continue } # Skip since it's already handled + $group = if ($CheckBox.Key.StartsWith("WPFInstall")) { "Install" } elseif ($CheckBox.Key.StartsWith("WPFTweaks")) { "WPFTweaks" } elseif ($CheckBox.Key.StartsWith("WPFFeature")) { "WPFFeature" } @@ -41,9 +51,7 @@ Function Get-WinUtilCheckBoxes { if ($CheckBox.Value.IsChecked -eq $true) { $feature = switch ($group) { "Install" { - # Get the winget value $wingetValue = $sync.configs.applications.$($CheckBox.Name).winget - if (-not [string]::IsNullOrWhiteSpace($wingetValue) -and $wingetValue -ne "na") { $wingetValue -split ";" } else { @@ -66,12 +74,12 @@ Function Get-WinUtilCheckBoxes { Write-Debug "Adding: $($feature) under: $($group)" $Output[$group] += $feature - if ($uncheck -eq $true) { + if ($unCheck) { $CheckBox.Value.IsChecked = $false } } } } - return $Output + return $Output } diff --git a/winutil.ps1 b/winutil.ps1 index 73b70c6f..77627c52 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -10,7 +10,7 @@ Author : Chris Titus @christitustech Runspace Author: @DeveloperDurp GitHub : https://github.com/ChrisTitusTech - Version : 24.05.01 + Version : 24.05.09 #> param ( [switch]$Debug, @@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms # Variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "24.05.01" +$sync.version = "24.05.09" $sync.configs = @{} $sync.ProcessRunning = $false @@ -351,8 +351,9 @@ function Get-TabXaml { } $appInfo = $organizedData[$panel][$category][$appName] if ("Toggle" -eq $appInfo.Type) { - $blockXml += "`n`n" + $blockXml += "`n" + $blockXml += "`n" + $blockXml += "`n" } elseif ("Combobox" -eq $appInfo.Type) { $blockXml += "`n