#Requires -RunAsAdministrator <# .SYNOPSIS Windows 11 Pro Performance Optimization Script .DESCRIPTION Automated optimization for blazing fast Windows 11 on laptops. Applies performance tweaks, disables bloat, and optimizes system settings. .NOTES Author: Automated Optimization Script Date: February 2026 WARNING: Creates restore point before making changes. #> # ============================================================ # CONFIGURATION # ============================================================ $ErrorActionPreference = "Continue" $ProgressPreference = "SilentlyContinue" # Color scheme for output function Write-Step { param([string]$Message) Write-Host "`n[$(Get-Date -Format 'HH:mm:ss')] " -ForegroundColor Cyan -NoNewline Write-Host "► $Message" -ForegroundColor White } function Write-Success { param([string]$Message) Write-Host " ✓ $Message" -ForegroundColor Green } function Write-Warning { param([string]$Message) Write-Host " ⚠ $Message" -ForegroundColor Yellow } function Write-Error { param([string]$Message) Write-Host " ✗ $Message" -ForegroundColor Red } # ============================================================ # HEADER # ============================================================ Clear-Host Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan Write-Host "║ Windows 11 Pro - Performance Optimization Script ║" -ForegroundColor Cyan Write-Host "║ Automated & Non-Interactive ║" -ForegroundColor Cyan Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan Write-Host "" # ============================================================ # 1. CREATE SYSTEM RESTORE POINT # ============================================================ Write-Step "Creating System Restore Point" try { Enable-ComputerRestore -Drive "$env:SystemDrive\" -ErrorAction SilentlyContinue Checkpoint-Computer -Description "Pre-Optimization-$(Get-Date -Format 'yyyy-MM-dd-HHmm')" -RestorePointType "MODIFY_SETTINGS" -ErrorAction Stop Write-Success "Restore point created successfully" } catch { Write-Warning "Could not create restore point (may require manual enable): $($_.Exception.Message)" } # ============================================================ # 2. SET POWER PLAN TO HIGH PERFORMANCE # ============================================================ Write-Step "Configuring Power Plan for Maximum Performance" try { # Enable Ultimate Performance if available $ultimateGuid = "e9a42b02-d5df-448d-aa00-03f14749eb61" powercfg -duplicatescheme $ultimateGuid 2>&1 | Out-Null # Get the cloned Ultimate Performance GUID $plans = powercfg /list $ultimatePlan = $plans | Select-String "Ultimate Performance" | ForEach-Object { if ($_ -match "([a-f0-9-]{36})") { $matches[1] } } if ($ultimatePlan) { powercfg /setactive $ultimatePlan Write-Success "Ultimate Performance power plan activated" } else { # Fallback to High Performance $highPerfGuid = "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c" powercfg /setactive $highPerfGuid Write-Success "High Performance power plan activated" } # Disable USB selective suspend powercfg /setacvalueindex SCHEME_CURRENT 2a737441-1930-4402-8d77-b2bebba308a3 48e6b7a6-50f5-4782-a5d4-53bb8f07e226 0 powercfg /setdcvalueindex SCHEME_CURRENT 2a737441-1930-4402-8d77-b2bebba308a3 48e6b7a6-50f5-4782-a5d4-53bb8f07e226 0 Write-Success "USB selective suspend disabled" # Disable hard disk timeout powercfg /setacvalueindex SCHEME_CURRENT 0012ee47-9041-4b5d-9b77-535fba8b1442 6738e2c4-e8a5-4a42-b16a-e040e769756e 0 Write-Success "Hard disk timeout disabled on AC power" } catch { Write-Error "Power plan configuration failed: $($_.Exception.Message)" } # ============================================================ # 3. DISABLE VISUAL EFFECTS FOR BEST PERFORMANCE # ============================================================ Write-Step "Optimizing Visual Effects for Performance" try { # Set visual effects to custom (best performance) Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" -Name "VisualFXSetting" -Value 2 -Type DWord -Force # Disable animations in accessibility settings Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Value 0 -Type String -Force # Disable transparency Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "EnableTransparency" -Value 0 -Type DWord -Force # Disable animation effects if (!(Test-Path "HKCU:\Software\Microsoft\Accessibility")) { New-Item -Path "HKCU:\Software\Microsoft\Accessibility" -Force | Out-Null } Set-ItemProperty -Path "HKCU:\Software\Microsoft\Accessibility" -Name "DynamicScrollbars" -Value 0 -Type DWord -Force Write-Success "Visual effects optimized for performance" Write-Success "Transparency effects disabled" Write-Success "Animation effects minimized" } catch { Write-Error "Visual effects optimization failed: $($_.Exception.Message)" } # ============================================================ # 4. OPTIMIZE SSD (TRIM & WRITE CACHE) # ============================================================ Write-Step "Optimizing SSD Performance" try { # Get all physical SSDs $ssds = Get-PhysicalDisk | Where-Object { $_.MediaType -eq "SSD" } foreach ($ssd in $ssds) { Write-Host " • Processing: $($ssd.FriendlyName)" -ForegroundColor Gray } # Run TRIM on all volumes Get-Volume | Where-Object { $_.DriveType -eq "Fixed" -and $_.DriveLetter } | ForEach-Object { try { Optimize-Volume -DriveLetter $_.DriveLetter -ReTrim -ErrorAction SilentlyContinue Write-Success "TRIM executed on drive $($_.DriveLetter):" } catch { Write-Warning "Could not TRIM drive $($_.DriveLetter): (may not be SSD)" } } # Enable write caching on all disks $disks = Get-WmiObject -Class Win32_DiskDrive foreach ($disk in $disks) { $disk.SetWriteCacheEnabled($true) | Out-Null } Write-Success "Write caching enabled on all drives" # Ensure TRIM is scheduled weekly $defragTask = Get-ScheduledTask -TaskName "ScheduledDefrag" -ErrorAction SilentlyContinue if ($defragTask) { $defragTask | Enable-ScheduledTask | Out-Null Write-Success "Weekly TRIM schedule confirmed active" } } catch { Write-Error "SSD optimization encountered errors: $($_.Exception.Message)" } # ============================================================ # 5. DISABLE STARTUP PROGRAMS (COMMON BLOAT) # ============================================================ Write-Step "Disabling Common Bloatware Startup Programs" try { $startupAppsToDisable = @( "Microsoft Teams", "Teams", "OneDrive", "Spotify", "Adobe*", "CCleaner*", "Discord", "Skype*", "iTunes*", "Zoom*" ) $disabledCount = 0 # Disable via Task Scheduler (startup apps) Get-CimInstance -ClassName Win32_StartupCommand | Where-Object { $app = $_ $startupAppsToDisable | ForEach-Object { if ($app.Name -like $_) { try { # Disable in registry $regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run" if (Test-Path $regPath) { $value = Get-ItemProperty -Path $regPath -Name $app.Name -ErrorAction SilentlyContinue if ($value) { Remove-ItemProperty -Path $regPath -Name $app.Name -Force -ErrorAction SilentlyContinue Write-Success "Disabled: $($app.Name)" $disabledCount++ } } } catch {} } } } if ($disabledCount -eq 0) { Write-Success "No common bloatware startup apps found (already clean)" } else { Write-Success "Disabled $disabledCount startup programs" } } catch { Write-Error "Startup program optimization failed: $($_.Exception.Message)" } # ============================================================ # 6. DISABLE GAME BAR, XBOX, AND TELEMETRY # ============================================================ Write-Step "Disabling Xbox Game Bar & Reducing Telemetry" try { # Disable Game Bar Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\GameDVR" -Name "AppCaptureEnabled" -Value 0 -Type DWord -Force Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_Enabled" -Value 0 -Type DWord -Force if (!(Test-Path "HKCU:\Software\Microsoft\GameBar")) { New-Item -Path "HKCU:\Software\Microsoft\GameBar" -Force | Out-Null } Set-ItemProperty -Path "HKCU:\Software\Microsoft\GameBar" -Name "AutoGameModeEnabled" -Value 0 -Type DWord -Force Write-Success "Xbox Game Bar disabled" # Disable Activity Feed Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\GameDVR" -Name "HistoricalCaptureEnabled" -Value 0 -Type DWord -Force -ErrorAction SilentlyContinue # Set telemetry to minimum (Security = 0, only works on Enterprise/Education; Basic = 1 for Pro) Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue Write-Success "Telemetry reduced to minimum (Basic)" # Disable feedback requests if (!(Test-Path "HKCU:\Software\Microsoft\Siuf\Rules")) { New-Item -Path "HKCU:\Software\Microsoft\Siuf\Rules" -Force | Out-Null } Set-ItemProperty -Path "HKCU:\Software\Microsoft\Siuf\Rules" -Name "NumberOfSIUFInPeriod" -Value 0 -Type DWord -Force Write-Success "Windows feedback requests disabled" } catch { Write-Error "Game Bar/Telemetry optimization failed: $($_.Exception.Message)" } # ============================================================ # 7. DISABLE BACKGROUND APPS PERMISSIONS (SYSTEM-WIDE) # ============================================================ Write-Step "Restricting Background App Activity" try { # Disable background apps globally if (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications")) { New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" -Force | Out-Null } Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" -Name "GlobalUserDisabled" -Value 1 -Type DWord -Force Write-Success "Background apps globally restricted" # Disable background apps for Store apps Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsRunInBackground" -Value 2 -Type DWord -Force -ErrorAction SilentlyContinue Write-Success "Store app background activity restricted" } catch { Write-Error "Background app restriction failed: $($_.Exception.Message)" } # ============================================================ # 8. WINDOWS UPDATE OPTIMIZATION # ============================================================ Write-Step "Optimizing Windows Update Settings" try { # Disable auto-restart after updates Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoRebootWithLoggedOnUsers" -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue Write-Success "Auto-restart after updates disabled" # Disable "Get the latest updates as soon as they're available" if (!(Test-Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings")) { New-Item -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Force | Out-Null } Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "IsContinuousInnovationOptedIn" -Value 0 -Type DWord -Force Write-Success "Continuous update delivery disabled" } catch { Write-Warning "Some Windows Update settings require Group Policy: $($_.Exception.Message)" } # ============================================================ # 9. DISABLE UNNECESSARY SERVICES # ============================================================ Write-Step "Disabling Non-Essential System Services" try { $servicesToDisable = @( "DiagTrack", # Connected User Experiences and Telemetry "dmwappushservice", # WAP Push Message Routing Service "RetailDemo", # Retail Demo Service "RemoteRegistry", # Remote Registry "Fax", # Fax "XblAuthManager", # Xbox Live Auth Manager "XblGameSave", # Xbox Live Game Save "XboxGipSvc", # Xbox Accessory Management Service "XboxNetApiSvc" # Xbox Live Networking Service ) foreach ($service in $servicesToDisable) { $svc = Get-Service -Name $service -ErrorAction SilentlyContinue if ($svc) { Stop-Service -Name $service -Force -ErrorAction SilentlyContinue Set-Service -Name $service -StartupType Disabled -ErrorAction SilentlyContinue Write-Success "Disabled service: $service" } } } catch { Write-Error "Service optimization failed: $($_.Exception.Message)" } # ============================================================ # 10. NETWORK OPTIMIZATION # ============================================================ Write-Step "Optimizing Network Settings" try { # Disable Windows Network Throttling Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile" -Name "NetworkThrottlingIndex" -Value 0xffffffff -Type DWord -Force Write-Success "Network throttling disabled" # Optimize network adapter settings $adapters = Get-NetAdapter | Where-Object { $_.Status -eq "Up" } foreach ($adapter in $adapters) { # Disable power management on network adapters $powerMgmt = Get-WmiObject MSPower_DeviceEnable -Namespace root\wmi | Where-Object { $_.InstanceName -match [regex]::Escape($adapter.PnPDeviceID) } if ($powerMgmt) { $powerMgmt.Enable = $false $powerMgmt.Put() | Out-Null Write-Success "Disabled power management on: $($adapter.Name)" } } } catch { Write-Warning "Network optimization partial: $($_.Exception.Message)" } # ============================================================ # 11. SYSTEM RESPONSIVENESS TWEAKS # ============================================================ Write-Step "Applying System Responsiveness Tweaks" try { # Improve system responsiveness Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile" -Name "SystemResponsiveness" -Value 10 -Type DWord -Force Write-Success "System responsiveness optimized (priority to foreground apps)" # Disable Prefetch and Superfetch on SSD systems $hasSSD = (Get-PhysicalDisk | Where-Object { $_.MediaType -eq "SSD" }).Count -gt 0 if ($hasSSD) { Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters" -Name "EnablePrefetcher" -Value 0 -Type DWord -Force Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters" -Name "EnableSuperfetch" -Value 0 -Type DWord -Force Stop-Service -Name "SysMain" -Force -ErrorAction SilentlyContinue Set-Service -Name "SysMain" -StartupType Disabled -ErrorAction SilentlyContinue Write-Success "Superfetch disabled (SSD detected)" } # Menu show delay optimization Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Value 0 -Type String -Force Write-Success "Menu show delay minimized" } catch { Write-Error "Responsiveness tweaks failed: $($_.Exception.Message)" } # ============================================================ # 12. CLEAN TEMP FILES # ============================================================ Write-Step "Cleaning Temporary Files" try { $tempPaths = @( "$env:TEMP\*", "$env:SystemRoot\Temp\*", "$env:SystemRoot\Prefetch\*" ) $cleanedMB = 0 foreach ($path in $tempPaths) { if (Test-Path $path) { $beforeSize = (Get-ChildItem -Path $path -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum / 1MB Remove-Item -Path $path -Recurse -Force -ErrorAction SilentlyContinue $cleanedMB += $beforeSize } } Write-Success "Cleaned $([math]::Round($cleanedMB, 2)) MB of temporary files" } catch { Write-Warning "Temp file cleanup partial: $($_.Exception.Message)" } # ============================================================ # SUMMARY & COMPLETION # ============================================================ Write-Host "`n╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Green Write-Host "║ OPTIMIZATION COMPLETED ║" -ForegroundColor Green Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Green Write-Host "" Write-Host "✓ Power plan: Ultimate/High Performance active" -ForegroundColor Green Write-Host "✓ Visual effects: Optimized for speed" -ForegroundColor Green Write-Host "✓ SSD: TRIM executed and scheduled" -ForegroundColor Green Write-Host "✓ Startup bloat: Reduced" -ForegroundColor Green Write-Host "✓ Background apps: Restricted" -ForegroundColor Green Write-Host "✓ Telemetry & Game Bar: Minimized" -ForegroundColor Green Write-Host "✓ Services: Non-essential disabled" -ForegroundColor Green Write-Host "✓ Network: Throttling removed" -ForegroundColor Green Write-Host "✓ System: Responsiveness improved" -ForegroundColor Green Write-Host "" Write-Host "⚠ IMPORTANT: Restart your computer to apply all changes!" -ForegroundColor Yellow Write-Host "" Write-Host "Press any key to exit..." -ForegroundColor Gray $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")