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!
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)
Please log in to answer
Posted by:
mekaywe
14 years ago
Posted by:
kardock
14 years ago
Posted by:
MSIPackager
14 years ago
Posted by:
LeeBerg
14 years ago
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.
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.