Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for sndisk2.bat

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

  1. @ECHO OFF
  2. :: Check Windows version: batch file not suited for DOS
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4.  
  5. :: Localize variables
  6. SETLOCAL
  7.  
  8. :: Check Windows version again: batch file not suited for NT 4
  9. VER | FIND.EXE /I "Windows NT" >NUL
  10. IF NOT ERRORLEVEL 1 GOTO Syntax
  11.  
  12. :: No command line arguments required
  13. IF NOT "%~1"=="" GOTO Syntax
  14.  
  15. :: Check availability and version of IBM's E-Gatherer tool
  16. ECHO N^| EGATHER2.EXE 2>&1 | FIND.EXE "2.37" >NUL
  17. IF ERRORLEVEL 1 GOTO Syntax
  18.  
  19. :: Check availability of SysInternals' PSList tool
  20. PSLIST.EXE >NUL 2>&1
  21. IF ERRORLEVEL 1 GOTO Syntax
  22.  
  23. :: Initialize variables
  24. SET SNDisk=0
  25. SET Counter=0
  26.  
  27. :: Start gathering system information
  28. START /MIN /LOW "Gathering info..." CMD.EXE /C (ECHO Y^| EGATHER2.EXE)
  29.  
  30. :Loop
  31. :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
  32. ::  Wait a quarter second.                            ::
  33. ::  Decrease the delay for really fast systems ! ! !  ::
  34. ::  This delay is far from accurate, so you may need  ::
  35. ::  to find other ways to generate a shorter delay.   ::
  36. :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
  37. PING 1.1.1.1 -n 1 -w 250 >NUL
  38.  
  39. :: Quit loop when ready
  40. IF %SNDisk%==1 IF NOT EXIST *.TMP GOTO LoopDone
  41. PSLIST.EXE egather2 >NUL 2>&1
  42. IF ERRORLEVEL 1 GOTO LoopDone
  43. :: As long as the temporary file exists -- is being built -- copy
  44. :: its contents to our own set of temporary files; variable SNDisk
  45. :: is set to 1 to signal being ready as soon as the temporary file
  46. :: is deleted by EGATHER2.
  47. IF EXIST egath*.tmp (
  48. 	SET SNDisk=1
  49. 	IF EXIST egath*.tmp FOR %%A IN (egath*.tmp) DO (COPY %%A %%~nA_%Counter%.xml >NUL 2>&1)
  50. )
  51. :: Increment counter and start loop procedure again
  52. SET /A Counter += 1
  53. GOTO Loop
  54.  
  55. :LoopDone
  56. :: Select and save the largest temporary file, which
  57. :: will ususally be the secondlast file created
  58. FOR /F "tokens=*" %%A IN ('DIR /B /OS egath*.xml') DO SET ResultFile=%%~nxA
  59. COPY %ResultFile% "%~dpn0.xml" >NUL 2>&1
  60.  
  61. :: Delete temporary files
  62. FOR %%A IN (*.EG2 SYS.GEL EGATH*.XML) DO (
  63. 	IF EXIST "%%~A" DEL "%%~A"
  64. ) >NUL 2>&1
  65.  
  66. :: Display results
  67. TYPE "%~dpn0.xml" | FIND.EXE "</GATHERED_DATA>" >NUL
  68. IF ERRORLEVEL 1 (
  69. 	ECHO The XML file containing the results is truncated.
  70. 	ECHO Please make sure this system has as little as possible other processes
  71. 	ECHO running, then rerun this batch file to try again.
  72. 	ECHO If the problem persists, decrease this batch file's delay time (read the
  73. 	ECHO comments in the batch file to find out what to change) and try again.
  74. ) ELSE (
  75. 	START "XML" "%~dpn0.xml"
  76. )
  77. GOTO End
  78.  
  79. :Syntax
  80. ECHO.
  81. ECHO SNDisk2.bat,  Version 1.00 for Windows 2000 / XP / Server 2003
  82. ECHO Display hardware characteristics using IBM's EGather2 tool
  83. ECHO (this batch file has been tested with EGather2 version 2.37 only).
  84. ECHO.
  85. ECHO IBM's EGather2 2.37 is used to gather and encode system information.
  86. ECHO This batch file copies EGather2's unencoded temporary file to an
  87. ECHO XML file which is then used to display some harddisk characteristics.
  88. ECHO.
  89. ECHO EGather2 can be downloaded at:
  90. ECHO http://www.pc.ibm.com/qtechinfo/MIGR-4R5VKC.html
  91. ECHO.
  92. ECHO This batch file uses PSList from SysInternals' PSTools.
  93. ECHO The PSTools can be downloaded at:
  94. ECHO http://www.sysinternals.com/ntw2k/freeware/pstools.shtml
  95. ECHO.
  96. ECHO Written by Rob van der Woude
  97. ECHO http://www.robvanderwoude.com
  98.  
  99. :End
  100. IF "%OS%"=="Windows_NT" ENDLOCAL
  101.  

page last uploaded: 2017-08-21, 14:26