Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for videorom.bat

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

  1. @ECHO OFF
  2. :: For Windows NT 4/2000/XP only
  3. IF NOT [%OS%]==[Windows_NT] GOTO Syntax
  4. :: No command line parameters required, "/2nd" is for internal use only
  5. IF NOT [%1]==[] IF NOT [%1]==[/2nd] GOTO Syntax
  6.  
  7. :: OK, let's go
  8. SETLOCAL
  9. IF [%1]==[/2nd] (
  10. 	:: DEBUG commands, to be piped to DEBUG.EXE
  11. 	FOR %%A IN ("d C000:0040" "d C000:00C0" "q") DO ECHO.%%~A
  12. ) ELSE (
  13. 	SET Info=
  14. 	:: Recursive call is needed to enable piping screen output to DEBUG.EXE
  15. 	FOR /F "tokens=16* delims= " %%A IN ('^(CMD.EXE /C "%~f0" /2nd 2^>NUL^) ^| DEBUG.EXE ^| FIND "C000:"') DO CALL :Parse "%%B"
  16. )
  17. :: Remove multiple dots
  18. CALL :StripDots
  19. :: Tidy up resulting string
  20. CALL :Tidy
  21. :: Show result
  22. ECHO.
  23. ECHO Video adapter ROM manufacturer info:
  24. ECHO.
  25. ECHO.%Info%
  26. :: Done
  27. ENDLOCAL
  28. GOTO:EOF
  29.  
  30.  
  31. :AddStr
  32. :: Remove quotes and append to existing string
  33. SET Info=%Info%%~1
  34. GOTO:EOF
  35.  
  36.  
  37. :Parse
  38. :: Remove "unprintable" characters
  39. SET Line=%1
  40. SET Line=%!!|%
  41. SET Line=%Line:<=%
  42. SET Line=%Line:>=%
  43. :: Remove quotes and append to existing string
  44. CALL :AddStr %Line%
  45. GOTO:EOF
  46.  
  47.  
  48. :Reverse
  49. :: Subroutine that reverses the specified input string
  50. :: Initialize variables
  51. SET Reverse=
  52. SET Input=%*
  53. :: Strip leading space in NT 4 only
  54. VER | FIND "Windows NT" >NUL
  55. IF NOT ERRORLEVEL 1 SET Input=%Input:~1%
  56. :Loop
  57. :: Continue till the input string's last character
  58. IF NOT DEFINED Input GOTO:EOF
  59. :: Separate first character from input string
  60. SET FirstChar=%Input:~0,1%
  61. SET Input=%Input:~1%
  62. :: Rebuild string in reverse order
  63. SET Reverse=%FirstChar%%Reverse%
  64. :: Next character
  65. GOTO Loop
  66.  
  67.  
  68. :StripDots
  69. :: Quit when no multiple dots are left
  70. ECHO.%Info% | FIND ".." >NUL
  71. IF ERRORLEVEL 1 GOTO:EOF
  72. :: Remove multiple dots
  73. SET Info=%Info:..=.%
  74. :: Repeat
  75. GOTO :StripDots
  76.  
  77.  
  78. :Tidy
  79. :: Split string at first space
  80. FOR /F "tokens=1* delims= " %%A IN ('ECHO.%Info%') DO (
  81. 	SET Prefix=%%A
  82. 	SET TempInfo=%%B
  83. )
  84. :: Quit if string wasn't split
  85. IF NOT DEFINED TempInfo GOTO:EOF
  86. :: Split at next space if first space was followed by a dot
  87. IF "%TempInfo:~0,1%"=="." FOR /F "tokens=1* delims= " %%A IN ('ECHO.%TempInfo%') DO (
  88. 	SET Prefix=%Prefix% %%A
  89. 	SET TempInfo=%%B
  90. )
  91. :: Quit if string wasn't split
  92. IF NOT DEFINED TempInfo GOTO:EOF
  93. :: Split at next space if previous space was followed by a dot
  94. IF "%TempInfo:~0,1%"=="." FOR /F "tokens=1* delims= " %%A IN ('ECHO.%TempInfo%') DO (
  95. 	SET Prefix=%Prefix% %%A
  96. 	SET TempInfo=%%B
  97. )
  98. :: Quit if string wasn't split
  99. IF NOT DEFINED TempInfo GOTO:EOF
  100. :: Reverse first part of string
  101. CALL :Reverse %Prefix%
  102. :: Quit if last character of first string part was a dot
  103. IF "%Reverse:~0,1%"=="." GOTO:EOF
  104. :: Remove everything after first dot, efectively keeping
  105. :: only the reversed last "word" of first part of string
  106. FOR /F "tokens=1 delims=." %%a IN ('ECHO.%Reverse%') DO SET Prefix=%%a
  107. :: Reverse again
  108. CALL :Reverse %Prefix%
  109. :: Concatenate the 2 parts
  110. SET Info=%Reverse% %TempInfo%
  111. GOTO:EOF
  112.  
  113.  
  114. :Syntax
  115. ECHO.
  116. ECHO VideoROM.cmd,  Version 4.00 for Windows NT 4 / 2000 / XP
  117. ECHO Reads and displays manufacturer information from your video adapter ROM
  118. ECHO.
  119. ECHO Usage:  %~n0
  120. ECHO.
  121. ECHO Written by Rob van der Woude
  122. ECHO http://www.robvanderwoude.com
  123. ECHO Original idea by ComputerHope
  124. ECHO http://www.computerhope.com/rdebug.htm
  125.  

page last modified: 2024-04-16; loaded in 0.0062 seconds