@echo off setlocal EnableExtensions net session >nul 2>&1 if errorlevel 1 ( echo Administrator rights are required. exit /b 1 ) set "TARGET=%SystemRoot%\Prefetch" if not exist "%TARGET%\" ( echo Folder not found: %TARGET% exit /b 1 ) echo Windows rebuilds prefetch data after cleanup. echo Prefetch files older than 30 days in %TARGET%: forfiles /p "%TARGET%" /m *.pf /d -30 /c "cmd /c echo @path" 2>nul echo. set "ANSWER=" set /p ANSWER=Delete these files? Type YES to continue: if /i not "%ANSWER%"=="YES" ( echo Cancelled. Nothing deleted. exit /b 0 ) forfiles /p "%TARGET%" /m *.pf /d -30 /c "cmd /c del /f /q @path" 2>nul echo Done. Prefetch will be rebuilt automatically. exit /b 0