hi again people,

we are having problems with a software that the vendor msi was poorly created. i have a software that has the same version & productcode as the precedent version. (some guys need to be kicked in the guts!)

i want to run a vbs before installing my package that will check if the product is already installed and if so, uninstall it.

i wish that the vbs interrogates the wmi system to see if it's installed or not.

does anyone could share a similar vbs that could show me how to code that vbs?

i don't wish anyone to do my work, i just need an example to get me started.

thanks all!

edit: crap i just saw that there is a scripting forum. sorry about that!
0 Comments   [ - ] Hide Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity


you can uninstall the earlier version using Wise Script... Write a WSE script to uninstall if earlier version is found... else Install the Newer Version.
Answered 03/15/2010 by: mekaywe
Brown Belt

Please log in to comment
yes i know about this but our distribution tool needs a vbs has a pre-installation script.

i need to run this script before launching the msi installation.

Answered 03/15/2010 by: kardock
Second Degree Green Belt

Please log in to comment
There's a pretty crude script here (no 4) which you can take the first part from to figure if a prodcut is installed via the ProductCode:


Hope it helps,
Answered 03/15/2010 by: MSIPackager
Third Degree Black Belt

Please log in to comment
great! this is a nice start for me!

thanks man!
Answered 03/16/2010 by: kardock
Second Degree Green Belt

Please log in to comment
In my packages I have vbscript functions setup to query the registry and/or file versions if needed.

Here is a cut up piece of script to check the registry, it is pretty rough but it works, you will run into issues if your registry has alot of junk entries.

Basically it is setting variables - it will go through each entry in the uninstall section of registry and check condition on values displayname and displayversion. If it finds a match it will set the UpdateNeeded variable as nessecary. After all keys in uninstall have been run through elseif statements will run through where you can use addition functions to install / uninstall / do whatever you want.

dim UpdateNeeded, RegistryDisplayName ,RegistryDisplayNewVersion ,RegistryDisplayOldVersion
strUninstallKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName"
strEntry1b = "DisplayVersion"
UpdateNeeded = 2

'setup vars
registryVersionCheck = 0
'If I use a registry version check use these variables:
RegistryDisplayName = "NAME" 'Value of Software for DisplayName
RegistryDisplayNewVersion = "VERSION" 'Value of Software for DisplayVersion
RegistryDisplayOldVersion = "VERSION" 'Value of Software for DisplayVersion

'call function

Function registrySoftwareVersionCheck
If RegistryVersionCheck = 1 Then
'registry pre-req check
Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
objReg.EnumKey HKLM, strUninstallKey, arrSubkeys

For Each strSubkey In arrSubkeys
'shouldnt have to use intRet1 and 2.....
intRet1 = objReg.GetStringValue(HKLM, strUninstallKey & strSubkey, strEntry1a, strValue1)
intRet2 = objReg.GetStringValue(HKLM, strUninstallKey & strSubkey, strEntry1b, strValue2)

If intRet1 <> 0 Then 'Grab ALL uninstall Guids in Registry for Name
objReg.GetStringValue HKLM, strUninstallKey & strSubkey, strValue1
End If

If intRet2 <> 0 Then 'Grab ALL uninstall Guids in Registry for Version
objReg.GetStringValue HKLM, strUninstallKey & strSubkey, strValue2
End If

If strValue1 = RegistryDisplayName and strValue2 = RegistryDisplayNewVersion Then
ProcessLogWriter (SoftwareShortName & " is at correct version: " & RegistryDisplayNewVersion)
UpdateNeeded = 0

end If

If strValue1 = RegistryDisplayName and strValue2 = RegistryDisplayOldVersion Then
ProcessLogWriter (SoftwareShortName & " is at OLD version: " & RegistryDisplayOldVersion1)
UpdateNeeded = 1
end If


If UpdateNeeded = 1 Then
'Software is old version
ElseIf UpdateNeeded = 2 Then
'Software is not installed
ElseIf UpdateNeeded = 0 Then
'Software is up to date
End If
Else 'registryVersionCheck = 0
'your variable for regcheck is set to 0 - skipping reg check
End If
End Function
Answered 03/17/2010 by: LeeBerg
Senior Yellow Belt

Please log in to comment
cool. many thanks!
Answered 03/17/2010 by: kardock
Second Degree Green Belt

Please log in to comment