/build/static/layout/Breadcrumb_cap_w.png

vbs help please

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   [ + ] Show comments

Answers (6)

Posted by: mekaywe 14 years ago
Brown Belt
0
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.
Posted by: kardock 14 years ago
Second Degree Green Belt
0
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.

thanks!
Posted by: MSIPackager 14 years ago
3rd Degree Black Belt
0
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:

http://www.drdobbs.com/windows/184416300;jsessionid=IHVHR53HMJKSXQE1GHRSKH4ATMY32JVN?pgno=10

Hope it helps,
Rob.
Posted by: kardock 14 years ago
Second Degree Green Belt
0
great! this is a nice start for me!

thanks man!
Posted by: LeeBerg 14 years ago
Senior Yellow Belt
0
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
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
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
registrySoftwareVersionCheck


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



Next


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
Posted by: kardock 14 years ago
Second Degree Green Belt
0
cool. many thanks!
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ