Powered by GeSHi

Source code for chkpath.bat

(view source code of chkpath.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4.  
  5. :: Check command line arguments
  6. IF NOT "%~2"=="" GOTO Syntax
  7. IF NOT "%~1"=="" IF /I NOT "%~1"=="/Q" GOTO Syntax
  8.  
  9. :: Enable delayed variable expansion
  10. SETLOCAL ENABLEDELAYEDEXPANSION
  11.  
  12. :: Initialize variables
  13. SET ChkPath=%Path:"=%
  14. SET Error=0
  15.  
  16. :: Check the first PATH entry, and remove it from the temporary path variable
  17. :Loop
  18. FOR /F "tokens=1* delims=;" %%A IN ("!ChkPath!") DO (
  19. 	IF EXIST %%A.\ (
  20. 		IF /I NOT "%~1"=="/Q" ECHO OK	%%A
  21. 	) ELSE (
  22. 		ECHO ERROR:	%%A
  23. 		SET Error=1
  24. 	)
  25. 	SET ChkPath=%%B
  26. )
  27. :: Repeat until there are no more PATH enries left
  28. IF NOT "%ChkPath%"=="" GOTO Loop
  29.  
  30. :: Exit with return code
  31. ENDLOCAL & EXIT /B %Error%
  32.  
  33.  
  34. :Syntax
  35. ECHO.
  36. ECHO ChkPath.bat,  Version 1.00 for Windows 2000 and later
  37. ECHO Verify if all PATH entries are valid directories
  38. ECHO.
  39. ECHO Usage:  CHKPATH  [ /Q ]
  40. ECHO.
  41. ECHO Where:             /Q    lists errors only (default: all entries)
  42. ECHO.
  43. ECHO Written by Rob van der Woude
  44. ECHO http://www.robvanderwoude.com
  45.