Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Detect IE version from batch file or command script

Posted on 2007-03-21
16
Medium Priority
?
3,345 Views
Last Modified: 2016-09-05
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?
0
Comment
Question by:johndeerb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
16 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18769098
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
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 18769115
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
 
LVL 4

Author Comment

by:johndeerb
ID: 18769121
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 67

Expert Comment

by:sirbounty
ID: 18769132
Hmm - I don't know that the scripting methods above will help you then...
What language are you using for the app?
0
 
LVL 4

Author Comment

by:johndeerb
ID: 18769133
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 18769137
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
 
LVL 4

Author Comment

by:johndeerb
ID: 18769145
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 18769149
Good luck to you... : ^)
0
 
LVL 4

Author Comment

by:johndeerb
ID: 18774025
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 18774076
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
 
LVL 4

Author Comment

by:johndeerb
ID: 18774077
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 18774099
Glad to hear it :)
Though the HKLM should also work...
0
 
LVL 4

Author Comment

by:johndeerb
ID: 18774113
Thanks again, sir...
I'd give you an A+ if there was one.
jb
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18774116
Happy to help> :^)
Thanx for the grade!
0
 

Expert Comment

by:arshad shaik
ID: 41782136
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 41785176
Maybe cliinfo or systeminfo would provide you some of that detail.  I suppose you could scrub the registry for anything omitted?
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question