Solved

Script to query IE version

Posted on 2008-10-21
7
4,334 Views
Last Modified: 2010-04-21
We are in the process of rolling out IE7 via group policy for a new web based application. Unfortunately some of our users have installed the Google Toolbar and the built in pop up blocker is causing problems with out web based app.

I would like to run a script in our logon script which reads the HKLM\Software\Microsoft\Internet Explorer\Version key, and then if the version is 7 or above, then I would like to execute a command to uninstall the Google Toolbar (I have this already).

Can anyone help?
Thanks
0
Comment
Question by:gladmins
[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
  • 4
  • 3
7 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 22772809
Hi, this code should read that value for you.

Regards,

Rob.
Set objShell = CreateObject("WScript.Shell")
strValue = objShell.RegRead("HKLM\Software\Microsoft\Internet Explorer\Version")
intVersion = CInt(Left(strValue, 1))
If intVersion >= 7 Then
	strCommand = "uninstall toolbar command"
	objShell.Run strCommand, 1, True
Else
	MsgBox "You have IE6 or less."
End If

Open in new window

0
 

Author Comment

by:gladmins
ID: 22773580
For some reason, I cant get this to work. I inserted the following text in place of "uninstall toolbar command".

 "C:\Program Files\Google\Google Toolbar\Component\GoogleToolbarManager_FE4264652A965D92.exe" /uninstall

I tried with double \ extra quotes

strCommand = ""C:\Program Files\Google\Google Toolbar\Component\GoogleToolbarManager_FE4264652A965D92.exe"" /uninstall

and I get an error saying line 5, char 17, expected end of statement, code 800A0401

With just the single quotes

strCommand = "C:\Program Files\Google\Google Toolbar\Component\GoogleToolbarManager_FE4264652A965D92.exe" /uninstall

I get error on line 5, char 2, type mismatch:'[string:"c:\program files\goo"]', code 800A000D.

Any idea what I am doing wrong? I've added the code snippet as well just in case.



Set objShell = CreateObject("WScript.Shell")
strValue = objShell.RegRead("HKLM\Software\Microsoft\Internet Explorer\Version")
intVersion = CInt(Left(strValue, 1))
If intVersion >= 7 Then
	strCommand = "C:\Program Files\Google\Google Toolbar\Component\GoogleToolbarManager_FE4264652A965D92.exe" /uninstall
	objShell.Run strCommand, 1, True
Else
	MsgBox "You have IE6 or less."
End If

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22773690
Hi, you need two double quotes around your .exe file path, so that that translates to being surrounded by quotes.  In VBScript, when you want to literally include a quote character in a string, you must double it.

Regards,

Rob.
Set objShell = CreateObject("WScript.Shell")
strValue = objShell.RegRead("HKLM\Software\Microsoft\Internet Explorer\Version")
intVersion = CInt(Left(strValue, 1))
If intVersion >= 7 Then
	strCommand = """C:\Program Files\Google\Google Toolbar\Component\GoogleToolbarManager_FE4264652A965D92.exe"" /uninstall"
	objShell.Run strCommand, 1, True
Else
	MsgBox "You have IE6 or less."
End If

Open in new window

0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 

Author Comment

by:gladmins
ID: 22773733
Thanks for the update Rob. The script now works a treat!
Just one more little question, and I'll hand over the points ;-)

I would just like to add a second command line that will uninstall a previous version of the toolbar. The actual command is...

regsvr32 /u /s "C:\Program Files\Google\GoogleToolbar1.dll"

Also, if either of the uninstall files dont exist, it would be better if an error didnt come up as it might halt the script. Is this possible?
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 22773753
Ok, sure.  I have added a check to see if each file exists, and if so, run the uninstall....

Regards,

Rob.
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strValue = objShell.RegRead("HKLM\Software\Microsoft\Internet Explorer\Version")
intVersion = CInt(Left(strValue, 1))
If intVersion >= 7 Then
	strFile = "C:\Program Files\Google\Google Toolbar\Component\GoogleToolbarManager_FE4264652A965D92.exe"
	If objFSO.FileExists(strFile) = True Then
		strCommand = """" & strFile & """ /uninstall"
		objShell.Run strCommand, 1, True
	End If
	strFile = "C:\Program Files\Google\GoogleToolbar1.dll"
	If objFSO.FileExists(strFile) = True Then
		strCommand = "regsvr32 /u /s """ & strFile & """"
		objShell.Run strCommand, 1, True
	End If
Else
	MsgBox "You have IE6 or less."
End If

Open in new window

0
 

Author Closing Comment

by:gladmins
ID: 31508577
Legend. Thanks for your help Rob. Got us out of a real bind. Cheers!
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22782262
No problem. Thanks for the grade.

Regards,

Rob.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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