• 0

Help with this script? (.bat)


Question

Not sure if this is in the right forum or not but...

Ok so I'm writing this script to install a patch and the XP version of the patch has two different version; one for IE6 and one for IE7.... so I'm trying to make a part of the script search for the version number in the registry... this is what I have so far but I don't know how to actually look for a specific string....

reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer

Now I want to tell it if version = 7 then go 'here' or if version = 6 then go 'there'...

Also I want it to just use the beginning version number, not the exact version number.... so instead of looking for 7.1.1.32 or 6.2.4.28 etc... I'd like it to just search for 7.* or 6.*

Can anyone provide any assistance with this? Thanks. :)

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Try this, there may be errors (and un-needed 'bloat').

The "for" and "findstr" commands are on the same line.

@echo off

set IEVER=

REM ** match against IE 7 version **
for /f "tokens=3*" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer" /v Version ^| findstr /r "7\..*$"') do (set IEVER=7)

REM ** match against IE 6 version **
for /f "tokens=3*" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer" /v Version ^| findstr /r "6\..*$"') do (set IEVER=6)

REM ** could not detect version **
if "%IEVER%"=="" goto error

:process
if "%IEVER%"=="6" goto ie6
if "%IEVER%"=="7" goto ie7
goto end

:ie6
echo You have IE 6.
goto end

:ie7
echo You have IE 7.
goto end

:error
echo.
echo Error: Could not detect IE version.
echo.

:end

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.