Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for iever.bat

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

  1. @ECHO OFF
  2. :: Check Windows version, command line arguments and availability of REG.EXE
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4. IF NOT "%~1"=="" GOTO Syntax
  5. REG.EXE /? >NUL 2>&1 || GOTO Syntax
  6.  
  7. :: Keep variables local
  8. SETLOCAL
  9.  
  10. :: Check Windows version
  11. IF NOT "%OS%"=="Windows_NT" GOTO End
  12.  
  13. :: Abort if any command line argument was passed
  14. IF NOT "%~1"=="" GOTO End
  15.  
  16. :: Define log file and directory here
  17. SET LogFile=\\ourserver\data\logs\IEVer.log
  18. SET LogFile=IEVer.log
  19.  
  20. :: Check today's date
  21. FOR /F "tokens=2-4* delims=- " %%A IN ('DATE/T') DO SET CurDate=%%C%%B%%A
  22.  
  23. :: Read IE version from registry and store it in a variable
  24. FOR /F "tokens=1*" %%A IN ('REG.EXE QUERY "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Version" 2^>NUL ^| FIND "REG_SZ"') DO FOR %%C IN (%%B) DO SET IEVer=%%C
  25. FOR /F "tokens=2*" %%A IN ('REG.EXE QUERY "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer" /V "Version" 2^>NUL ^| FIND "REG_SZ"') DO SET IEVer=%%B
  26. IF "%IEVer%"=="" GOTO End
  27.  
  28. :: Display result
  29. > CON ECHO.
  30. > CON ECHO %ComputerName%	%CurDate%	%UserName%	%IEVer%
  31.  
  32. :: Check if a log entry for this computer was made already today
  33. IF NOT EXIST %LogFile% GOTO Log
  34. TYPE %LogFile% | FIND "%ComputerName%	%CurDate%" >NUL
  35. IF NOT ERRORLEVEL 1 GOTO End
  36.  
  37. :: Log result
  38. :Log
  39. IF NOT EXIST %LogFile% (
  40. 	> %LogFile% ECHO Computer	Date	User	IE version
  41. )
  42. >> %LogFile% ECHO %ComputerName%	%CurDate%	%UserName%	%IEVer%
  43.  
  44. :: End program
  45. :End
  46. ENDLOCAL
  47. GOTO:EOF
  48.  
  49.  
  50. :Syntax
  51. > CON ECHO.
  52. > CON ECHO IEVer.bat,  Version 3.00 for Windows NT 4 and later
  53. > CON ECHO Logs Internet Explorer version (only once each day)
  54. > CON ECHO.
  55. > CON ECHO Usage:  IEVER
  56. > CON ECHO.
  57. > CON ECHO Note:   Requires REG.EXE, native in Windows 2000 and later,
  58. > CON ECHO         or available in the Windows NT 4 Resource Kits
  59. > CON ECHO.
  60. > CON ECHO Written by Rob van der Woude
  61. > CON ECHO http://www.robvanderwoude.com
  62.  
  63. IF NOT "%OS%"=="Windows_NT" COLOR 00
  64.  

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