bluebearr Posted August 17, 2006 Posted August 17, 2006 This was a happy little discovery. There are places in the registry you can search to see if a program is installed, but they can be uncertain if the installation has been damaged. As far as I can determine, this is the "official" way to query Windows Installer to see if a product is installed. You have to know the product GUID in order to use this. ; http://windowssdk.msdn.microsoft.com/en-us/library/ms707471.aspx ; INSTALLSTATE_ABSENT The product is installed for a different user. ; INSTALLSTATE_ADVERTISED The product is advertised but not installed. ; INSTALLSTATE_DEFAULT The product is installed for the current user. ; INSTALLSTATE_INVALIDARG An invalid parameter was passed to the function. ; INSTALLSTATE_UNKNOWN The product is neither advertised or installed. Const $INSTALLSTATE_ABSENT = 2, $INSTALLSTATE_ADVERTISED = 1 Const $INSTALLSTATE_DEFAULT = 5, $INSTALLSTATE_INVALIDARG = -2 Const $INSTALLSTATE_UNKNOWN = -1 $prodName = "Microsoft Office XP Professional" $prodCode = "{90110409-6000-11D3-8CFE-0050048383C9}" $IsInstalled = DllCall("msi.dll", "int", "MsiQueryProductStateA", "str", $prodCode) ;MsgBox(0, "Return", "Return Code : " & $IsInstalled[0]) Select Case $IsInstalled[0] = $INSTALLSTATE_ABSENT $msg = " is installed for a different user." Case $IsInstalled[0] = $INSTALLSTATE_ADVERTISED $msg = " is advertised." Case $IsInstalled[0] = $INSTALLSTATE_UNKNOWN $msg = " is not installed." Case $IsInstalled[0] = $INSTALLSTATE_DEFAULT $msg = " is installed." Case Else $msg = ": The program's install state could not be determined." EndSelect MsgBox(0, "Install Test", $prodName & $msg) Other keywords: msiexec BlueBearrOddly enough, this is what I do for fun.
WTS Posted August 17, 2006 Posted August 17, 2006 (edited) pretty cool.. Edited August 17, 2006 by WTS
jftuga Posted August 18, 2006 Posted August 18, 2006 What about $prodCode? How does one obtain this? -John Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile
bluebearr Posted August 18, 2006 Author Posted August 18, 2006 Easiest way to find the GUID (prodcode) is to go to a system where you know the software is installed, open the registry to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, and search for the name of the software. You'll find the name in a subkey called DisplayName, and the GUID will be the key that contains this value, like so: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90110409-6000-11D3-8CFE-0050048383C9}] "DisplayName"="Microsoft Office XP Professional" BlueBearrOddly enough, this is what I do for fun.
davil Posted September 28, 2006 Posted September 28, 2006 Ok what about checking the version? and maybe writing to a text file rather than to screen?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now