Advertisement
Guest User

Advanced NVIDIA & DirectX Cache Cleanup

a guest
Jun 16th, 2025
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Winbatch 2.80 KB | Gaming | 0 0
  1. @echo off
  2. title Advanced NVIDIA & DirectX Cache Cleanup
  3.  
  4. :: Section 1: Administrator Check
  5. ::-----------------------------------------------------------------------------
  6. echo Verifying Administrator privileges...
  7. net session >nul 2>&1
  8. if %errorLevel% NEQ 0 (
  9.     echo.
  10.     echo ======================================================================
  11.     echo ^> ERROR: Administrator privileges are required to run this script.
  12.     echo ^> Please right-click this .cmd file and select "Run as administrator".
  13.     echo ======================================================================
  14.     echo.
  15.     pause
  16.     exit /b
  17. )
  18. echo Privileges verified.
  19.  
  20. :: Section 2: Stop Locking Processes and Services
  21. ::-----------------------------------------------------------------------------
  22. echo.
  23. echo [ACTION] Stopping processes and services that may lock cache files...
  24.  
  25. :: Kill the Windows process known to lock GPU caches
  26. taskkill /F /IM TextInputHost.exe >nul 2>&1
  27. if %errorLevel% EQU 0 (echo    - Process "TextInputHost.exe" stopped.)
  28.  
  29. :: Kill the main NVIDIA process
  30. taskkill /F /IM nvcontainer.exe >nul 2>&1
  31. if %errorLevel% EQU 0 (echo    - Process "nvcontainer.exe" stopped.)
  32.  
  33. :: Stop the NVIDIA services by name
  34. net stop "NvContainerLocalSystem" >nul 2>&1
  35. if %errorLevel% EQU 0 (echo    - Service "NvContainerLocalSystem" stopped.)
  36.  
  37. net stop "NVDisplay.ContainerLocalSystem" >nul 2>&1
  38. if %errorLevel% EQU 0 (echo    - Service "NVDisplay.ContainerLocalSystem" stopped.)
  39.  
  40. echo.
  41. echo Waiting for 3 seconds for file locks to be released...
  42. timeout /t 3 /nobreak > NUL
  43.  
  44. :: Section 3: Clear Cache Directories
  45. ::-----------------------------------------------------------------------------
  46. echo.
  47. echo [ACTION] Clearing all identified shader cache directories...
  48.  
  49. call :ClearCacheFolder "%localappdata%\NVIDIA\DXCache"
  50. call :ClearCacheFolder "%localappdata%\NVIDIA\GLCache"
  51. call :ClearCacheFolder "%localappdata%\NVIDIA Corporation\NV_Cache"
  52. call :ClearCacheFolder "%localappdata%\D3DSCache"
  53. del "%localappdata%\FortniteGame\Saved\FortniteGame_PCD3D_SM6.upipelinecache"
  54.  
  55. :: Section 4: Finalization
  56. ::-----------------------------------------------------------------------------
  57. echo.
  58. echo ======================================================================
  59. echo ^> Cache cleanup complete.
  60. echo ^> The stopped processes and services will restart automatically as needed.
  61. echo ======================================================================
  62. echo.
  63. echo This window will close in 3 seconds...
  64. timeout /t 3
  65. exit /b
  66.  
  67.  
  68. :: Subroutine to clear a folder's contents
  69. :ClearCacheFolder
  70. echo    - Clearing folder: %~1
  71. if not exist %~1 (
  72.     echo        (Does not exist, skipping)
  73.     goto :EOF
  74. )
  75. pushd %~1
  76. del /q /s /f *.* >nul 2>&1
  77. for /d %%i in (*) do (
  78.     rmdir /s /q "%%i" >nul 2>&1
  79. )
  80. popd
  81. goto :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement