Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for isdev.cmd

(view source code of isdev.cmd as plain text)

  1. @ECHO OFF
  2. :: Checks if %1 is a valid OS/2 or NT device name
  3.  
  4. ECHO.
  5. IF "%1"=="" GOTO Syntax
  6. IF "%1"=="/?" GOTO Syntax
  7.  
  8. :: OS/2 or NT?
  9. IF "%OS%"=="Windows_NT" GOTO NT
  10.  
  11. :OS2
  12. :: Based on the fact that OS/2 devices are
  13. :: always "located" in the "directory" \DEV
  14. DIR %1 2>&1 | FIND "\\DEV" >NUL
  15. IF     ERRORLEVEL 1 ECHO.%1 is NOT a valid OS/2 device name
  16. IF NOT ERRORLEVEL 1 ECHO.%1 is a valid OS/2 device name
  17. GOTO End
  18.  
  19. :NT
  20. :: Based on the fact that DIR doesn't show a volume label for devices
  21. DIR %1 2>&1 | FIND /I "Volume" >NUL
  22. IF ERRORLEVEL 1 (ECHO.%1 is a valid NT device name) ELSE (ECHO.%1 is NOT a valid NT device name)
  23. GOTO End
  24.  
  25. :Syntax
  26. ECHO IsDev.cmd,  Version 2.00 for Windows NT/2000 and OS/2
  27. ECHO Checks if the specified parameter is a valid device name
  28. ECHO.
  29. ECHO Usage:  ISDEV  ^<device_name^>
  30. ECHO.
  31. ECHO Written by Rob van der Woude
  32. ECHO http://www.robvanderwoude.com
  33.  
  34. :End
  35.  

page last uploaded: 2017-04-06, 13:33