Skip to content

Instantly share code, notes, and snippets.

@1337cookie
Last active March 2, 2024 04:22
Show Gist options
  • Save 1337cookie/54e9d34e02946d369b61c58be089aa6f to your computer and use it in GitHub Desktop.
Save 1337cookie/54e9d34e02946d369b61c58be089aa6f to your computer and use it in GitHub Desktop.
DeleteDiscordCache.ps1
# Deletes some discord cache files which can cause video stream to be low quality, jittery or lowered bitrate.
# You can run this with discord running and it should restart discord afterwards.
$answer = [System.Windows.Forms.MessageBox]::Show("Do you want to clear discord cache files","Do you really want to been as far even as decided to use even go want to do look more like?", "YesNo", "Hand", "Button1")
if($answer -match 'No'){
Write-Output $answer
exit
}
# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
Exit
}
}
$nid = Get-Process discord -ErrorAction SilentlyContinue
Write-Host $nid
ForEach($process in $nid){
Stop-Process $process
}
ForEach($process IN $nid){
Wait-Process $process
}
Remove-Item $env:appdata\discord\Cache\* -Recurse
Remove-Item "$env:appdata\discord\Code Cache\*" -Recurse
Remove-Item "$env:appdata\discord\GPUCache\*" -Recurse
Remove-Item "$env:appdata\discord\Crashpad\*" -Recurse
Start-Process -FilePath "$env:localappdata\Discord\Update.exe" -ArgumentList "--processStart Discord.exe"
@1337cookie
Copy link
Author

To download, right click "Raw" button in the top right of code area and click "Save link as".
To Run right click the file and click "Run with Powershell"
This is for Windows not OSX or Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment