Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- title Advanced NVIDIA & DirectX Cache Cleanup
- :: Section 1: Administrator Check
- ::-----------------------------------------------------------------------------
- echo Verifying Administrator privileges...
- net session >nul 2>&1
- if %errorLevel% NEQ 0 (
- echo.
- echo ======================================================================
- echo ^> ERROR: Administrator privileges are required to run this script.
- echo ^> Please right-click this .cmd file and select "Run as administrator".
- echo ======================================================================
- echo.
- pause
- exit /b
- )
- echo Privileges verified.
- :: Section 2: Stop Locking Processes and Services
- ::-----------------------------------------------------------------------------
- echo.
- echo [ACTION] Stopping processes and services that may lock cache files...
- :: Kill the Windows process known to lock GPU caches
- taskkill /F /IM TextInputHost.exe >nul 2>&1
- if %errorLevel% EQU 0 (echo - Process "TextInputHost.exe" stopped.)
- :: Kill the main NVIDIA process
- taskkill /F /IM nvcontainer.exe >nul 2>&1
- if %errorLevel% EQU 0 (echo - Process "nvcontainer.exe" stopped.)
- :: Stop the NVIDIA services by name
- net stop "NvContainerLocalSystem" >nul 2>&1
- if %errorLevel% EQU 0 (echo - Service "NvContainerLocalSystem" stopped.)
- net stop "NVDisplay.ContainerLocalSystem" >nul 2>&1
- if %errorLevel% EQU 0 (echo - Service "NVDisplay.ContainerLocalSystem" stopped.)
- echo.
- echo Waiting for 3 seconds for file locks to be released...
- timeout /t 3 /nobreak > NUL
- :: Section 3: Clear Cache Directories
- ::-----------------------------------------------------------------------------
- echo.
- echo [ACTION] Clearing all identified shader cache directories...
- call :ClearCacheFolder "%localappdata%\NVIDIA\DXCache"
- call :ClearCacheFolder "%localappdata%\NVIDIA\GLCache"
- call :ClearCacheFolder "%localappdata%\NVIDIA Corporation\NV_Cache"
- call :ClearCacheFolder "%localappdata%\D3DSCache"
- del "%localappdata%\FortniteGame\Saved\FortniteGame_PCD3D_SM6.upipelinecache"
- :: Section 4: Finalization
- ::-----------------------------------------------------------------------------
- echo.
- echo ======================================================================
- echo ^> Cache cleanup complete.
- echo ^> The stopped processes and services will restart automatically as needed.
- echo ======================================================================
- echo.
- echo This window will close in 3 seconds...
- timeout /t 3
- exit /b
- :: Subroutine to clear a folder's contents
- :ClearCacheFolder
- echo - Clearing folder: %~1
- if not exist %~1 (
- echo (Does not exist, skipping)
- goto :EOF
- )
- pushd %~1
- del /q /s /f *.* >nul 2>&1
- for /d %%i in (*) do (
- rmdir /s /q "%%i" >nul 2>&1
- )
- popd
- goto :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement