@echo off setlocal EnableExtensions net session >nul 2>&1 if errorlevel 1 ( echo Administrator rights are required. exit /b 1 ) set "WER=%ProgramData%\Microsoft\Windows\WER" if not exist "%WER%\" ( echo Folder not found: %WER% exit /b 1 ) echo Report files older than 30 days: for %%D in (ReportQueue ReportArchive) do ( if exist "%WER%\%%D\" ( forfiles /p "%WER%\%%D" /s /m * /d -30 /c "cmd /c if @isdir==FALSE 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 ) for %%D in (ReportQueue ReportArchive) do ( if exist "%WER%\%%D\" ( forfiles /p "%WER%\%%D" /s /m * /d -30 /c "cmd /c if @isdir==FALSE del /f /q @path" 2>nul ) ) echo Done. exit /b 0