Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for sndisk4.bat

(view source code of sndisk4.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. :: No command line arguments allowed
  6. IF NOT "%~1"=="" GOTO Syntax
  7.  
  8. :: Check if EGatherer 2.51.* is located in the same directory as this script
  9. IF NOT EXIST "%~dp0egather2-2.51.*" GOTO Syntax
  10.  
  11. :: Enable delayed variable expansion
  12. SETLOCAL ENABLEDELAYEDEXPANSION
  13.  
  14. :: Check if this is a 64-bit OS
  15. SET OS=
  16. FOR /F "tokens=2 delims==" %%A IN ('WMIC Path Win32_Processor Get AddressWidth /Format:list 2^>NUL') DO (
  17. 	IF "%%~A"=="64" (
  18. 		SET OS=-64OS
  19. 	)
  20. )
  21.  
  22. :: Find the most recent EGatherer 2.51.* and extract its worker files
  23. SET EG=
  24. FOR %%A IN (egather2-2.51.*) DO SET EG=%%~fA
  25. SET Started=0
  26. START /B "" "!EG!"
  27.  
  28. :Loop1
  29. TASKLIST /FI "IMAGENAME eq worker.exe" 2>NUL | FINDSTR /R /B /I /C:"worker\.exe " >NUL && SET Started=1
  30. IF %Started%==1 (
  31. 	TASKKILL /FI "IMAGENAME eq worker.exe" >NUL 2>&1
  32. ) ELSE (
  33. 	PING 127.0.0.1 -n 1 -w 250 >NUL 2>&1
  34. 	GOTO Loop1
  35. )
  36.  
  37. :: Run EGatherer silently
  38. PUSHD C:\IBM_Support\Egatherer
  39. START /B eg2.exe -silent %OS%
  40.  
  41. :: As long as the process is running, copy the contents of its temporary file
  42. :Loop2
  43. FOR %%A IN (ega*.tmp) DO (
  44. 	TYPE %%A >NUL
  45. 	COPY /Y %%A "%~dpn0.xml" >NUL 2>&1
  46. )
  47. TASKLIST /FI "IMAGENAME eq eg2.exe" 2>NUL | FINDSTR /R /B /I /C:"eg2\.exe " >NUL && GOTO Loop2
  48.  
  49. :: Clean up the mess
  50. POPD
  51. RD /S /Q C:\IBM_Support
  52.  
  53. :: Open the resulting XML file
  54. START "" "%~dpn0.xml"
  55.  
  56. GOTO End
  57.  
  58.  
  59. :Syntax
  60. ECHO.
  61. ECHO SNDisk4.bat,  Version 1.00 for Windows XP and later
  62. ECHO Save a full inventory in XML using IBM's EGather2 Version 2.51
  63. ECHO.
  64. ECHO Usage:  SNDISK4
  65. ECHO.
  66. ECHO Notes:  All inventory details will be stored in sndisk4.xml
  67. ECHO         in the same directory as this batch file.
  68. ECHO         EGather2-2.51.*.exe must also be located in the same
  69. ECHO         directory as this batch file.
  70. ECHO         IBM's EGather2 can be found at (URL wrapped):
  71. ECHO         http://www.ibm.com/systems/support/supportsite.wss
  72. ECHO         /docdisplay?brandind=5000008^&lndocid=MIGR-4R5VKC
  73. ECJO         Tested with EGather2-2.51.0374.exe on Windows 7 64-bit.
  74. ECHO.
  75. ECHO Written by Rob van der Woude
  76. ECHO http://www.robvanderwoude.com
  77.  
  78.  
  79. :End
  80. IF "%OS%"=="Windows_NT" ENDLOCAL
  81.  

page last uploaded: 2017-07-06, 12:37