Page 1 of 1 1
Topic Options
#130795 - 2004-12-07 11:02 PM Check if MSI installed???
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
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

Top
#130796 - 2004-12-07 11:08 PM Re: Check if MSI installed???
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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
_________________________
!

download KiXnet

Top
#130797 - 2004-12-07 11:21 PM Re: Check if MSI installed???
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
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.

Top
#130798 - 2004-12-07 11:23 PM Re: Check if MSI installed???
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
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.

Top
#130799 - 2004-12-08 01:31 AM Re: Check if MSI installed???
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
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.
_________________________
There are two types of vessels, submarines and targets.

Top
#130800 - 2004-12-08 05:59 AM Re: Check if MSI installed???
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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?
_________________________
!

download KiXnet

Top
#130801 - 2004-12-08 04:41 PM Re: Check if MSI installed???
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
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!!


Top
#130802 - 2004-12-09 04:59 AM Re: Check if MSI installed???
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
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.

Top
#130803 - 2004-12-09 09:53 AM Re: Check if MSI installed???
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
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





Top
#130804 - 2004-12-09 10:55 AM Re: Check if MSI installed???
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#130805 - 2004-12-09 09:57 PM Re: Check if MSI installed???
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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 $

_________________________
!

download KiXnet

Top
#130806 - 2004-12-11 12:05 AM Re: Check if MSI installed???
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
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???
Top
#130807 - 2004-12-11 12:57 AM Re: Check if MSI installed???
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
that is the name windows installer knows as the source filename of the package.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.06 seconds in which 0.022 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org