Script that searches up GUID in registry key & installs if not found
Can someone help me out with finding specific GUID's and if it's found, go to the next process, and if not, install a msi. I'm trying to install an application with pre-requisites, and don't have the conditions right now.
-
Hi guy , do you want a install or launch condition for the MSI ? Instead to do it by script, you can use the MSI features ... make a Install Condition with the System Search and looking for the Registry entry. - egiberne 11 years ago
Answers (3)
here you go:
Const HKEY_LOCAL_MACHINE =&H80000002Dim RegKey 'Dim objWshShell'Set objWshShell = CreateObject("WScript.shell")' strComputer ="."'Set objRegistry = GetObject("winmgmts:\\"& strComputer &"\root\default:StdRegProv")' RegKey="test" strKeyPath ="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"' objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath&"\"&RegKey,"",strValue ''check if the value existsIf IsNull(strValue)Then'the key doesnt exist wsh.echo "Not found"
'run your install code here else wsh.echo "Found:", strValue EndIf
Here is a script i use for checking if the product is installed or not. It works on both 32bit and 64bit machines.
'****************************
'Declaration
'****************************
Dim Installer
Dim productcode
'****************************
'Initialisation
'****************************
ArgProductcode = "{XXX-XXX-XXX}" 'Enter the required Product code
set Installer = CreateObject("WindowsInstaller.Installer")
Set ProductCodes = CreateObject ("System.Collections.ArrayList")
'****************************
'Execution
'***************************
ProductCodes.Add ArgProductcode
For each productcode in Productcodes
if Installer.ProductState(productcode) = 5 then
Msgbox "found"
Else
Msgbox "not found"
End If
Next
'****************************
'Termination
'***************************
Set ProductCodes = Nothing
set Installer = Nothing
Here is another method you can use. Either from a script or a custom action within MSI.
http://www.itninja.com/blog/view/searching-for-installed-msi-s-via-wisescript