-
Notifications
You must be signed in to change notification settings - Fork 14
/
clear-cache-browser.ps1
1 lines (1 loc) · 1.26 KB
/
clear-cache-browser.ps1
1
$browser=(Get-ItemProperty "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId;$logPath="$env:UserProfile\Desktop\cache_cleanup_log.txt";if($browser-eq"MSEdgeHTM"){$cachePath="$env:LocalAppData\Microsoft\Edge\User Data\Default\Cache\*";Remove-Item $cachePath-Recurse-Force;if(-not(Get-ChildItem"$env:LocalAppData\Microsoft\Edge\User Data\Default\Cache"-Recurse-ErrorAction SilentlyContinue)){Add-Content -Path $logPath -Value "Edge cache cleared on $(Get-Date)";Write-Host "Edge cache cleared."}}elseif($browser-eq"ChromeHTML"){$cachePath="$env:LocalAppData\Google\Chrome\User Data\Default\Cache\*";Remove-Item $cachePath-Recurse-Force;if(-not(Get-ChildItem"$env:LocalAppData\Google\Chrome\User Data\Default\Cache"-Recurse-ErrorAction SilentlyContinue)){Add-Content -Path $logPath -Value "Chrome cache cleared on $(Get-Date)";Write-Host "Chrome cache cleared."}}elseif($browser-eq"FirefoxURL"){$cachePath="$env:AppData\Mozilla\Firefox\Profiles\*\cache2\*";Remove-Item $cachePath-Recurse-Force;if(-not(Get-ChildItem"$env:AppData\Mozilla\Firefox\Profiles\*\cache2"-Recurse-ErrorAction SilentlyContinue)){Add-Content -Path $logPath -Value "Firefox cache cleared on $(Get-Date)";Write-Host "Firefox cache cleared."}}else{Write-Host "Unsupported browser."}