×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

comparing installed version with downloaded MSI version

comparing installed version with downloaded MSI version

comparing installed version with downloaded MSI version

(OP)
Hi,

I am trying to compare the currently installed Google Version via the registry with the version inside the latest one's internal MSI database. This code looks choppy and probably could stand some cleaning up. What I having trouble with is the if statement below that determines if the MSI gets installed. When the installed version is the same or greater it should simply exit. Right now it appears to be doing a re-install or repair. Can someone suggest what needs to be cleaned up?

'Check version of Chrome presently installed
strComputer = "."
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product where (Caption='Google Chrome')")
For Each objSoftware in colSoftware
wscript.echo objSoftware.Version
Next

'Check version of the downloaded MSI file
Dim Installer
Set Installer = CreateObject("WindowsInstaller.Installer")
'Open the MSI database. You may change the path information as you like.
Dim Database
Set Database = Installer.OpenDatabase("c:\windows\temp\GoogleChromeStandaloneEnterprise.msi", 0)
'Create the SQL statement for query
Dim SQL
SQL = "SELECT * FROM Property WHERE Property = 'ProductVersion'"
'Open the view and execute the SQL statement
Dim View
Set View = DataBase.OpenView(SQL)
View.Execute
'Fetch the record for the "ProductVersion" property
Dim Record
Set Record = View.Fetch
'Show the result.
MsgBox Record.StringData(2)
If objSoftware.Version < Record Then
WshShell.Run "msiexec.exe /I c:\windows\temp\GoogleChromeStandaloneEnterprise.msi env=prod /qb!"
End If

If objSoftware > Record Then
WScript.echo "Installed version is same or newer than downloaded version"

End If

Thanks kindly.

RE: comparing installed version with downloaded MSI version

I would start by determining the exact values of objSoftware.Version and Record, and then determine why objSoftware.Version < Record is not returning the value that you are expecting.

Also for readability, please surround your code in [code][/code] tags.

RE: comparing installed version with downloaded MSI version

(OP)
Let me start with the top portion of the code that deals with the registry. It does return the version installed correctly via the echo command. The bottom portion of the code that deals with querying the MSI file that too confirms the version that was downloaded with the msg box command.

If the 'version' (registry) is older than the 'record' (MSI internal DB query) then it should run the WshShell.Run command to install the newest Chrome. That works when the installed Chrome is older than the Chrome in the MSI file. What is not happening is I don't think it is even getting to the 2nd If statement when the installed Chrome is the same or newer than the one in the MSI. I see a repair or reinstall being done. That leads me to believe the first If-Else is incorrect somwhere. Do keep in mind these were 2 separate vbscripts that I tried to merge together.

You may have already put the pieces together in your head as well and I am not trying to sound like a record skipping. I am trying to reason this out in my head by writing this out again.

RE: comparing installed version with downloaded MSI version

The > operator performs an alphabetic comparison if used on two strings, which often will not work with version numbers. You may need to break each part of the version up and compare each part. Depends on what objSoftware.Version and Record contain. The link below illustrates one way.

http://www.posteet.com/view/206

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close