@echo off setlocal EnableExtensions set "action=%~1" if "%action%"=="" set "action=show" if /i "%action%"=="show" goto show if /i "%action%"=="save" goto save if /i "%action%"=="flush" goto flush goto usage :show echo Current DNS cache: ipconfig /displaydns exit /b 0 :save set "out=%~2" if "%out%"=="" set "out=%TEMP%\dns-cache.txt" ipconfig /displaydns > "%out%" if errorlevel 1 ( echo Could not save DNS cache. exit /b 1 ) for %%A in ("%out%") do echo Saved: "%out%" (%%~zA bytes) exit /b 0 :flush echo This clears the local DNS resolver cache. set /p "answer=Continue? [y/N] " if /i not "%answer%"=="y" ( echo Cancelled. exit /b 0 ) ipconfig /flushdns if errorlevel 1 exit /b 1 echo DNS cache cleared. exit /b 0 :usage echo Usage: %~nx0 [show^|save^|flush] [output-file] exit /b 2