thepip3r
(Hey THIS is FUN)
2005-05-05 12:53 AM
Quick UDF Question: Does one exist that checks for installed programs?

I ran a search on the UDF section and couldn't find one but wasn't sure if anyone knew of one that I may have missed? Is there a UDF out there that checks to see if a program is installed or not???

Les
(KiX Master)
2005-05-05 01:04 AM
Re: Quick UDF Question: Does one exist that checks for installed programs?

Several UDFs check for specific apps but there is no universal checker.

Les
(KiX Master)
2005-05-05 01:07 AM
Re: Quick UDF Question: Does one exist that checks for installed programs?

Since you can form a WMI query to check for installed software, I guess I was wrong. The WMIQuery() UDF would match your requirement.

Jose
(Seasoned Scripter)
2005-05-05 01:09 AM
Re: Quick UDF Question: Does one exist that checks for installed programs?

This could do.
Code:
  
$ProgramArray=GetUninstallInfo()

For Each $Program In $ProgramArray
If $Program="your program"
? "found it!"
EndIf
Next

Sleep 4

Function GetUninstallInfo()
Dim $Index, $Key, $RC, $Value, $RootKey
Dim $progs[0]
$Index = 0

$RootKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

$Key = EnumKey($RootKey, $Index)
While @Error = 0
ReDim PRESERVE $progs[$Index]
$RC = EnumValue($RootKey + $Key, 1)
If @Error = 0
$Value = ReadValue($RootKey + $Key, "DisplayName")
If $Value = ""
$Value = ReadValue($RootKey + $Key, "QuietDisplayName")
If $Value = ""
$Value = $Key
EndIf
EndIf
Else
$Value = $Key
EndIf
;? $Value
$progs[$Index] = $Value
$Index = $Index + 1
$Key = EnumKey($RootKey, $Index)
Loop
$GetUninstallInfo = $progs
EndFunction



If you dont have the exact description of the program you might want to use InStr( ) to check the presence of your soft when you do the For Each..


thepip3r
(Hey THIS is FUN)
2005-05-05 01:10 AM
Re: Quick UDF Question: Does one exist that checks for installed programs?

Les, since I know you're knowledgeable on KiX and the Windows Registry, if I wanted to write a UDF that would check for the existance of an installed program, what keys would be the most accurate to check and what should be the criteria for the search? Is there a display name key or something?

thepip3r
(Hey THIS is FUN)
2005-05-05 01:12 AM
Re: Quick UDF Question: Does one exist that checks for installed programs?

sorry all, those posts happened while i was writing my last one. Thanx for the info and examples guys!

Les
(KiX Master)
2005-05-05 01:15 AM
Re: Quick UDF Question: Does one exist that checks for installed programs?

Not all apps install the same way so there is not one universal way to check for all apps. The Add/Remove check that Jose has is one possible way, WMI another and following the trail of clues starting at "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths", yet another. Some require you follow a more obscure trail starting at HKCR.

NTDOCAdministrator
(KiX Master)
2005-05-05 02:24 AM
Re: Quick UDF Question: Does one exist that checks for installed programs?

Quote:

checks to see if a program is installed or not




Well since you're only wanting to determine if 1 application is installed why not just say what application here and maybe we already have code for it, or can whip some up real quick for you.

Please let us know the name of the application.


thepip3r
(Hey THIS is FUN)
2005-05-05 04:58 PM
Re: Quick UDF Question: Does one exist that checks for installed programs?

I appreciate the offer NTDOC but I just wanted to make an addition to my MySQL install script so that I could ensure the script wasn't kicking off the MSI every time a user logged in. Jose's example of GetUninstallInfo() works great. When the MySQL MSI is installed it creates an uninstall key called MyODBC so it was an easy one to check for. Thanx again though guys, the information is always helpful. =D