Advertisement
aveyo

clear_shader_cache

May 14th, 2024 (edited)
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.91 KB | Gaming | 0 0
  1. @(set ^ "0=%~f0" -d ' .bat or .ps1 script ) & powershell -nop -c . ([scriptblock]::Create((gc $env:0)-join \"`n\")) & exit /b ')
  2.  
  3. "`n  CLEAR SHADER CACHE `n"       # AveYo, 17.05.2024    Never use the preview text from pastebin! click copy, raw or download
  4.  
  5. $run = {
  6.   # AveYo: detect STEAM and specific APPS
  7.   $steam = resolve-path (gpv "HKCU:\SOFTWARE\Valve\Steam" SteamPath)
  8.   $apps  = @{id = 730; name='cs2'; root='Counter-Strike Global Offensive'; game='csgo'},
  9.            @{id = 570; name='dota2'; root='dota 2 beta'; game='dota'}
  10.   gc "$steam\steamapps\libraryfolders.vdf" |foreach  {$_ -split '"',5} |where {$_ -like '*:\\*'} |foreach {
  11.     $l = resolve-path $_; $apps |foreach { if (test-path "$l\steamapps\appmanifest_$($_.id).acf") { $_.lib = "$l\steamapps"
  12.       $game = "$($_.lib)\common\$($_.root)\game"; $_.exe = "$game\bin\win64\$($_.name).exe"; $_.path = "$game\$($_.game)"
  13.   }}}
  14.  
  15.   "`n close STEAM and APPS "
  16.   $apps |foreach { if (ps -name $_.name -ea 0) {"$($_.name) is running..."; kill -name $_.name -force} }
  17.   if (ps -name 'steam' -ea 0) {"Steam is running..."; start "$steam\Steam.exe" -args '-shutdown' -wait; sleep 5 }
  18.  
  19.   "`n empty STEAM logs "
  20.   mkdir "$steam\logs\-EMPTY-" -force >''; robocopy "$steam\logs\-EMPTY-/" "$STEAM\logs/" /MIR /R:1 /W:0 /ZB >''
  21.  
  22.   "`n empty STEAM crash dumps "
  23.   mkdir "$steam\dumps\-EMPTY-" -force >''; robocopy "$steam\dumps\-EMPTY-/" "$STEAM\dumps/" /MIR /R:1 /W:0 /ZB >''
  24.  
  25.   "`n empty APPS crash dumps "
  26.   $apps |foreach { if ($_.exe) { del "$(split-path $_.exe)\*.mdmp" -force } }
  27.  
  28.   "`n empty APPS shadercache "
  29.   $apps |foreach { $t = @("$($_.path)\shadercache", "$($_.lib)\shadercache\$($_.id)")
  30.     if ($_.lib -ne "$steam\steamapps") { $t += "$steam\steamapps\shadercache\$($_.id)" } ; $t |foreach { if (test-path $_) {
  31.       "$_"; mkdir "$_\-EMPTY-" -force >''; robocopy "$_\-EMPTY-/" "$_/" /MIR /R:1 /W:0 /ZB >''
  32.   }}}
  33.  
  34.   "`n empty Compute cache "
  35.   $t = "$([Environment]::GetFolderPath('ApplicationData'))\NVIDIA\ComputeCache"; if (test-path $t) {
  36.     $t; mkdir "$t\-EMPTY-" -force >''; robocopy "$t\-EMPTY-/" "$t/" /MIR /R:1 /W:0 /ZB >''
  37.   }
  38.  
  39.   "`n empty NV cache "
  40.   $t = "$([Environment]::GetFolderPath('CommonApplicationData'))\NVIDIA Corporation\NV_Cache"; if (test-path $t) {
  41.     $t; mkdir "$t\-EMPTY-" -force >''; robocopy "$t\-EMPTY-/" "$t/" /MIR /R:1 /W:0 /ZB >''
  42.   }
  43.  
  44.   "`n empty Local shader cache "
  45.   'D3DSCache','NVIDIA\GLCache','NVIDIA\DXCache','NVIDIA\OptixCache','NVIDIA Corporation\NV_Cache',
  46.   'AMD\DX9Cache','AMD\DxCache','AMD\DxcCache','AMD\GLCache','AMD\OglCache','AMD\VkCache','Intel\ShaderCache' |foreach {
  47.     $t = "$([Environment]::GetFolderPath('LocalApplicationData'))\$_"; if (test-path $t) {
  48.       $t; mkdir "$t\-EMPTY-" -force >''; robocopy "$t\-EMPTY-/" "$t/" /MIR /R:1 /W:0 /ZB >''
  49.   }}
  50.  
  51.   "`n empty LocalLow shader cache "
  52.   'NVIDIA\PerDriverVersion\DXCache','NVIDIA\PerDriverVersion\GLCache','Intel\ShaderCache' |foreach {
  53.     $t = "$(split-path ([Environment]::GetFolderPath('LocalApplicationData')))\LocalLow\$_"; if (test-path $t) {
  54.       $t; mkdir "$t\-EMPTY-" -force >''; robocopy "$t\-EMPTY-/" "$t/" /MIR /R:1 /W:0 /ZB >''
  55.   }}
  56.  
  57.   "`n empty driver temp "
  58.   "$env:systemdrive\AMD","$env:systemdrive\NVIDIA","$env:systemdrive\Intel" |foreach { if (test-path $_) {
  59.     mkdir "$_\-EMPTY-" -force >''; robocopy "$_\-EMPTY-/" "$_/" /MIR /R:1 /W:0 /ZB >''
  60.   }}
  61.  
  62.   timeout -1
  63. }
  64.  
  65. sp HKCU:\Console\cmd ScreenColors 0x0b -type Dword -ea 0; sp HKCU:\Console\cmd QuickEdit 0 -type Dword -ea 0
  66.  
  67. # AveYo: $run elevated
  68. if ([Security.Principal.WindowsIdentity]::GetCurrent().Groups.Value -notcontains 'S-1-5-32-544') {
  69.   write-host " Requesting ADMIN rights.. " -fore Black -back Yellow; sleep 2; $_="$env:temp\runas.Admin"; sc $_ $run -force -ea 0
  70.   start cmd -args "/x /d /r start `"cmd`" powershell -nop -c . ([scriptblock]::Create((gc \`"$_\`")-join \`"``n\`"))" -verb runas
  71. } else { . $run }
  72.  
  73. $_press_enter_if_copy_pasted_to_powershell
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement