Created
December 3, 2024 22:28
-
-
Save jamesy0ung/b187b022c9bf7a6dde30f4b14fa50d72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure the script is running as Administrator | |
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
Write-Output "Please run this script as an Administrator!" | |
Exit | |
} | |
# Define the registry paths to clean | |
$graphicsDriversPath = "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers" | |
$subKeys = @("Configuration", "Connectivity", "ScaleFactors") | |
# Delete the profiles under each subkey | |
foreach ($subKey in $subKeys) { | |
$fullPath = Join-Path $graphicsDriversPath $subKey | |
if (Test-Path $fullPath) { | |
Get-ChildItem $fullPath | ForEach-Object { | |
Remove-Item -Path $_.PSPath -Recurse -Force | |
} | |
Write-Output "Cleared $subKey under GraphicsDrivers." | |
} else { | |
Write-Output "$subKey does not exist or has already been cleared." | |
} | |
} | |
Write-Output "Display cache cleared. Please restart your computer for changes to take effect." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment