Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for bootdriv.bat

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

  1. @ECHO OFF
  2. :: BOOTDRV.BAT
  3. :: Places the boot drive letter in environment variable BOOTDRV
  4. ::
  5. :: Written by Rob van der Woude
  6. :: http://www.xs4all.nl/~robw/rob/
  7. ::
  8. :: Limitation: Uses COMSPEC to determine boot drive, so if a different
  9. ::             command processor was specified by either the SHELL
  10. ::             command or by a SET COMSPEC=... command, this batch file
  11. ::             will be fooled and display the wrong drive.
  12. ::
  13. SET BOOTDRV=
  14. ECHO %COMSPEC% | CHOICE /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ > NUL
  15. IF ERRORLEVEL  1 SET BOOTDRV=A
  16. IF ERRORLEVEL  2 SET BOOTDRV=B
  17. IF ERRORLEVEL  3 SET BOOTDRV=C
  18. IF ERRORLEVEL  4 SET BOOTDRV=D
  19. IF ERRORLEVEL  5 SET BOOTDRV=E
  20. IF ERRORLEVEL  6 SET BOOTDRV=F
  21. IF ERRORLEVEL  7 SET BOOTDRV=G
  22. IF ERRORLEVEL  8 SET BOOTDRV=H
  23. IF ERRORLEVEL  9 SET BOOTDRV=I
  24. IF ERRORLEVEL 10 SET BOOTDRV=J
  25. IF ERRORLEVEL 11 SET BOOTDRV=K
  26. IF ERRORLEVEL 12 SET BOOTDRV=L
  27. IF ERRORLEVEL 13 SET BOOTDRV=M
  28. IF ERRORLEVEL 14 SET BOOTDRV=N
  29. IF ERRORLEVEL 15 SET BOOTDRV=O
  30. IF ERRORLEVEL 16 SET BOOTDRV=P
  31. IF ERRORLEVEL 17 SET BOOTDRV=Q
  32. IF ERRORLEVEL 18 SET BOOTDRV=R
  33. IF ERRORLEVEL 19 SET BOOTDRV=S
  34. IF ERRORLEVEL 20 SET BOOTDRV=T
  35. IF ERRORLEVEL 21 SET BOOTDRV=U
  36. IF ERRORLEVEL 22 SET BOOTDRV=V
  37. IF ERRORLEVEL 23 SET BOOTDRV=W
  38. IF ERRORLEVEL 24 SET BOOTDRV=X
  39. IF ERRORLEVEL 25 SET BOOTDRV=Y
  40. IF ERRORLEVEL 26 SET BOOTDRV=Z
  41. IF     "%BOOTDRV%"=="" ECHO Error checking boot drive
  42. IF NOT "%BOOTDRV%"=="" ECHO Boot drive is %BOOTDRV%:
  43.  

page last uploaded: 2016-12-15, 11:20