(view source code of chkpath.bat as plain text)
@ECHO OFF
:: Check Windows version
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
:: Check command line arguments
IF NOT "%~2"=="" GOTO Syntax
IF NOT "%~1"=="" IF /I NOT "%~1"=="/Q" GOTO Syntax
:: Enable delayed variable expansion
SETLOCAL ENABLEDELAYEDEXPANSION
:: Initialize variables
SET ChkPath=%Path:"=%
SET Error=0
:: Check the first PATH entry, and remove it from the temporary path variable
:Loop
FOR /F "tokens=1* delims=;" %%A IN ("!ChkPath!") DO (
IF EXIST %%A.\ (
IF /I NOT "%~1"=="/Q" ECHO OK %%A
) ELSE (
ECHO ERROR: %%A
SET Error=1
)
SET ChkPath=%%B
)
:: Repeat until there are no more PATH enries left
IF NOT "%ChkPath%"=="" GOTO Loop
:: Exit with return code
ENDLOCAL & EXIT /B %Error%
:Syntax
ECHO.
ECHO ChkPath.bat, Version 1.00 for Windows 2000 and later
ECHO Verify if all PATH entries are valid directories
ECHO.
ECHO Usage: CHKPATH [ /Q ]
ECHO.
ECHO Where: /Q lists errors only (default: all entries)
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
page last modified: 2024-04-16; loaded in 0.0071 seconds