Detect IE version from batch file or command script

I have a .cmd script built for an installer application, and I need to be able to detect what version of Internet Explorer is on the PC from within the script.  I thought about using reg.exe to output the registry key to a temporary .txt file and then reading the file to find the version key.  This seems klunky to me and I don't really like poking around in the users registry or creating files on their machines.  Can anyone think of a cleaner way?
LVL 4
johndeerbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sirbountyCommented:
Are you opposed to a vbscript method?

This will echo the version to the screen (2 lines).

Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
wscript.echo objFSO.GetFileVersion("C:\Program Files\Internet Explorer\iexplore.exe")


What do you need to do with the version data?
You can run a script based upon the version...

Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objShell: Set objShell=CreateObject("Wscript.Shell")
IEVersion=objFSO.GetFileVersion("C:\Program Files\Internet Explorer\iexplore.exe")
Select Case IEVersion
  Case "6.0.2900.2180" 'IE6
    objShell.Run "c:\ie6.bat"
  Case Else 'not IE6
    objShell.Run "c:\otherIE.bat"
End Select

Or, you can simply write it to a text file...

Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
IEVersion=objFSO.GetFileVersion("C:\Program Files\Internet Explorer\iexplore.exe")
Dim objFile: Set objFile=objFSO.CreateTextFile("C:\IEVersion.txt")
objFile.WriteLine IEVersion
objFile.Close
0
sirbountyCommented:
The above, obviously, assumes that iexplore is installed in the default location.

The command-line 'reg' version would be simply:

reg query "hklm\software\microsoft\internet explorer" /v Version

And you could get a varialbe with the version by using:

for /f "skip=2 tokens=3" %a in ('reg query "hklm\software\microsoft\internet
 explorer" /v Version') do set IEVer=%a

or, if placing in a batch file: (double up on the %s)

for /f "skip=2 tokens=3" %%a in ('reg query "hklm\software\microsoft\internet
 explorer" /v Version') do set IEVer=%%a

But, this limits the user to having admin permissions - which most users don't...so they won't be able to read the hklm string.

However, you can do so from a remote workstation using

for /f "skip=2 tokens=3" %%a in ('reg query "\\ComputerA\hklm\software\microsoft\internet
 explorer" /v Version') do set IEVer=%%a

or even loop through a list of computers like:

For /f %%a in (C:\Computers.txt) do call :process %%a
goto :eof

:process
Set pc=%1
for /f "skip=2 tokens=3" %%x in ('reg query "\\%pc%\hklm\software\microsoft\internet
 explorer" /v Version') do echo %pc% has IE version %%a >> C:\IE_Results.txt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
johndeerbAuthor Commented:
Your lightening fast, sir...

I am making a CD to send out for a simple task to build a connection to an unpublished IP web application.  It will autorun a html file with links to steps in the connection, one of which is to install IE6 if needed.  The app requires >= IE6, so I want to detect the version and if needed, launch the ie6 installer.  The problem is that our folks don't want me to have anything on the page that requires the user to have their IE security set to allow scripting.  SO, I thought if I just linked to a local .cmd script from the welcome page then it won't matter if their browsers allow scripting to run on the welcome page...
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

sirbountyCommented:
Hmm - I don't know that the scripting methods above will help you then...
What language are you using for the app?
0
johndeerbAuthor Commented:
Does the user have to be a local admin to read from any key in the registry?  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet explorer for example...
(Sorry I am not a real registry guru...)
Thanks!
jb
0
sirbountyCommented:
HKLM - is the Local Machine - yes, the user would need admin access (85% sure of that...)

HKCU - no, this is the Current User key and the user typically has full rights to this hive.  

You 'may' get read access to the hklm using reg.exe, but I doubt it...
I don't know much about your app or procedures here, but I wonder if you couldn't script something to automate that simple reg query under the local system credentials...just have System output the detail to a text file for you - maybe to the global %temp% path...
0
johndeerbAuthor Commented:
The app is a canned solution from a vendor.  My task is just to build a connection to get folks into it.  I have redirected a couple of IP addresses on our firewall, so now I need to send a simple installer out to get folks up to requirements (IE6, java 1.4.2) and allow a connection(add 2 entries into hosts file).  Since IE now blocks scripts from running on the page by default, I was afraid to use vbscript to handle the install because I don't want a bunch of phone calls from folks who don't notice the yellow bar.

Maybe I'll test tomorrow on some machines in house and verify whether a non-admin user can query the registry keys you mentioned.  If that don't work, I guess it's vbscript and strict instructions, huh?

Thanks!!
jb
0
sirbountyCommented:
Good luck to you... : ^)
0
johndeerbAuthor Commented:
Looks like any user can query the HKLM keys using reg.exe but I'm having trouble getting the variable assignment to stick.  I ran your code:
for /f "skip=2 tokens=3" %%a in ('reg query "hklm\software\microsoft\internet
 explorer" /v Version') do set IEVer=%%a
in a command script followed by a line:
ECHO %IEVer%
and didn't get an echo.  Am I missing something?
Thanks!
jb
0
sirbountyCommented:
If you run it from a command line, only use one % sign...

for /f "skip=2 tokens=3" %a in ('reg query "hklm\software\microsoft\internet
 explorer" /v Version') do set IEVer=%a
0
johndeerbAuthor Commented:
Never mind.. I'm an idiot.

I changed the code to:
for /f "skip=2 tokens=3" %%a in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer" /v Version') do set IEVer=%%a

ECHO Version is %IEVer%

and it is kind enough to echo the actual version number.

Thanks!!!
jb
0
sirbountyCommented:
Glad to hear it :)
Though the HKLM should also work...
0
johndeerbAuthor Commented:
Thanks again, sir...
I'd give you an A+ if there was one.
jb
0
sirbountyCommented:
Happy to help> :^)
Thanx for the grade!
0
arshad shaikCommented:
Hi sir bounty ..Im working with IT security team so i need to login into all my server and need to take print screen of IE version details and SEP version details Windows update print screen ..is this possible to get this all the info by run batch file or script
0
sirbountyCommented:
Maybe cliinfo or systeminfo would provide you some of that detail.  I suppose you could scrub the registry for anything omitted?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.