sliver
(Getting the hang of it)
2004-12-07 11:02 PM
Check if MSI installed???

Anyone know of an easy way using kix to check if an MSI is installed on a machine or not. I looked in the UDF's but didn't see andything pertaining to an MSI. I know about the:
HKCU\Software\Microsoft\Installer\Products\Productcode
and
HKLM\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\UserSID\Products\ProductCode

but the productcode seems to be a randomly generated number so I would have to parse through all productcodes to find the correct one (kinda bulky). Anyone else know of an easier way?? I actually want to install an msi and then check something to make sure it was installed correctly.

Thanks in advance


LonkeroAdministrator
(KiX Master Guru)
2004-12-07 11:08 PM
Re: Check if MSI installed???

MSI is installed on all modern OS'es, no?
the only question is what is the version of it.

try this for some info:
Code:

$=createobject("windowsinstaller.installer")
if vartype($)=9
$.version ?
else
"weird, no installer object available" ?
endif
get $


for example, on my machine it gives 2.0.2600.1183


sliver
(Getting the hang of it)
2004-12-07 11:21 PM
Re: Check if MSI installed???

I'm sorry...not the version of msiexec but if an actual msi is installed on a machine or not.

Ex.-

Shell "c:\winnt\system32\msiexec.exe /i c:\test.msi /qn-"

Is there a way to check if an msi installed correctly after you run the command above?? Or you only want to install said msi if it has not already been installed.


NTDOCAdministrator
(KiX Master)
2004-12-07 11:23 PM
Re: Check if MSI installed???

Well if you're checking only for 1 application then just check the registry directly where it modifies it.

Add/Remove should also have an entry in most cases.

Also, check the file/s that are installed by the MSI.

There is also a log file you can check, and the event logs too.


Sealeopard
(KiX Master)
2004-12-08 01:31 AM
Re: Check if MSI installed???

Check the Uninstall registry subkey of the installed application where the .MSI file was located when the application was installed. Then use EXIST to check for the presene of the .MSI file.

LonkeroAdministrator
(KiX Master Guru)
2004-12-08 05:59 AM
Re: Check if MSI installed???

sliver, do you wanna see for the MSI file if it's installed?
or if the product is installed?
Code:

$=createobject("windowsinstaller.installer")
$bk="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
for each $product in $.products
"MSI key: " $product ?
"Soft name: " readvalue($bk+$product,"displayname") ?
?
next

get $



hmm...
I think I'm getting closer to what you got there in my mind.
you gonna have huge bunch of self made msi-packages and you would like to have suits-you-sir-suits-you-all-method to check each one, right?


sliver
(Getting the hang of it)
2004-12-08 04:41 PM
Re: Check if MSI installed???

Yes closer to what I want...i can use that uninstall location to do what I need. The problem is we have a custom install that uses kix as a wrapper to kick off multiple self-made msi's. Some users already have certain msi's installed and for some unknown reason it is causing errors if we try to reinstall...I wanted to check machine before each msi in the kix package is installed to make sure that the msi was not installed already and either install it or uninstall it based on this. Thanks for your help!!



NTDOCAdministrator
(KiX Master)
2004-12-09 04:59 AM
Re: Check if MSI installed???

You could easily add the names of the MSI installs to an array even if there were 40 installs, and do an scan of that array against the Registry. KiX should be able to run that kind of code in under a second. Then take action as needed. If you need an example let us know.


NTDOCAdministrator
(KiX Master)
2004-12-09 09:53 AM
Re: Check if MSI installed???

Okay Silver, Here is some 95% SILVER-PLATTER code ... give this a try. Simply find/locate the names of the applications you want to check for and edit the $Installs array var to include those names exactly as they are in the Registry. This script should then show any of your custom installed applications.

Then add / edit for the rest of what you're looking to do like launching or not launching code based upon the results.

The ArrayEnumKey UDF was written by Sealeopard. This and 490+ other UDFs can easily be searched/found here

USA
http://www.kixhelp.com/udfs/

Finland
http://www.gwspikval.com/jooel/UDF/


Code:
Break On

Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('WrapAtEOL','On')

Dim $HKLMSCIP,$HKLMSCIPDATA,$Entry,$HKLMSCIPAPP,$Installs
$HKLMSCIP='HKLM\SOFTWARE\Classes\Installer\Products'
$HKLMSCIPDATA=ArrayEnumKey($HKLMSCIP)
$Installs='MSI Custom 1','MSI Custom 2','MSI Custom 3'

For Each $Entry In $HKLMSCIPDATA
If $Entry
$HKLMSCIPAPP=ReadValue($HKLMSCIP+'\'+$Entry,'ProductName')
If AScan ($Installs, $HKLMSCIPAPP)>=0
? $HKLMSCIPAPP
EndIf
EndIf
Next

Function ArrayEnumKey($regsubkey)
dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray
if not keyexist($regsubkey)
exit 87
endif
$subkeycounter=0
do
$currentsubkey=enumkey($regsubkey,$subkeycounter)
if not @ERROR
redim preserve $subkeyarray[$subkeycounter]
$subkeyarray[$subkeycounter]=$currentsubkey
$subkeycounter=$subkeycounter+1
endif
until @ERROR
$arrayenumkey=$subkeyarray
exit 0
EndFunction






LonkeroAdministrator
(KiX Master Guru)
2004-12-09 10:55 AM
Re: Check if MSI installed???

now, the code can be lot simpler.
sliver, check for the installer-object list... does all your MSI's show up in that list?
if yes, then you don't need to go to the reg key at all.


LonkeroAdministrator
(KiX Master Guru)
2004-12-09 09:57 PM
Re: Check if MSI installed???

to clarify what I mean:
Code:

$=createobject("windowsinstaller.installer")
$bk="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
for each $product in $.products
"MSI key: " $product ?
"Soft name: " readvalue($bk+$product,"displayname") ?
"productInfo: " $.productinfo($product,"PackageName") ?
?
next

get $


k, there you got all msi's, right?
so here is msi installed udf:
Code:

function msiInstalled(optional $msi)
$msiInstalled=0
$=createobject("windowsinstaller.installer")
for each $product in $.products
if $msi = $.productinfo($product,"PackageName")
$msiInstalled=1
endif
next
endfunction



so, to see if netframework is installed:
Code:
msiInstalled("netFX.msi") ?

function msiInstalled(optional $msi)
$msiInstalled=0
$=createobject("windowsinstaller.installer")
for each $product in $.products
if $msi = $.productinfo($product,"PackageName")
$msiInstalled=1
endif
next
endfunction

get $



sliver
(Getting the hang of it)
2004-12-11 12:05 AM
Re: Check if MSI installed???

Geez...i was actually signing off in that last post and you guys just kept giving me better stuff. Thats why I love this sight...you guys really are the best!! Anyway...before I saw what you guys wrote I actually just starting checking for the presence of the MSI GUID (in the uninstall key...I knew what all the GUIDs were because I created the MSI's. ) Everything worked out great with that but I will mess with the MSI UDF...that looks nice too. Does that actually just look for the name of the MSI when it was installed???

LonkeroAdministrator
(KiX Master Guru)
2004-12-11 12:57 AM
Re: Check if MSI installed???

that is the name windows installer knows as the source filename of the package.