treborhudson
2nd March 2004 00:34 UTC
Check if ... is installed
I've been tasked to put together the functionality we need to check for various programs and their versions that our programs depend on, and if they aren't installed or they don't have the minimum version, offer to install or point to the place to install, etc.
I know in the archives there are various checkers. Which is typically the most robust way to check for the existence and version of X program?
I've seen:
* Look in the HKCR for existence (flash)
* Do a GetDllVersion (IE)
* Check in registry (HKLM) for a version number (windows)
Is it whatever works? Do all programs typically do each of these?
Thanks.
Joel
2nd March 2004 01:41 UTC
Depends.
If you are looking for a file than check its version,
I'll do a search, with IfFileExists than check its version with GetDLLVersion.
kichik
5th March 2004 09:53 UTC
In my opnion, it is best to check as much as possible. The best test is calling a few functions you need and verify that they preform as you would expect.
Brummelchen
5th March 2004 12:44 UTC
especially flash:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{D27CDB6E-AE6D-11CF-96B8-444553540000} [Version]
and
HKEY_CLASSES_ROOT\CLSID\{D27CDB70-AE6D-11cf-96B8-444553540000}\InprocServer32 [""]
(Standard = %systemroot%\system32\macromed\flash\Flash.ocx)
Current here 7,0,19,0
Check Registry and file and version match of file (possible)
Function getfilever
; grab version of installed file
Exch $0 ; file to grab
Exch
Push $R0
Push $R1
Push $R2
Push $R3
Push $R4
Push $R5
GetDllVersion $0 $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $0 "$R2.$R3.$R4.$R5"
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Pop $R0
Exch
Exch $0
FunctionEnd
Damn - i forgot something...
registry saves with comma ',' file with a point '.'
7.0.19.0 <> 7,0,19,0
use this one:
Push $string_from_registry
Push ","
Push "."
Call StrRep
Pop $file_version_with_points
; Usage
; Push String to do replacement in (haystack)
; Push String to replace (needle)
; Push Replacement
; Call StrRep
; Pop $R0 result
Function StrRep
Exch $R4 ; $R4 = Replacement String
Exch
Exch $R3 ; $R3 = String to replace (needle)
Exch 2
Exch $R1 ; $R1 = String to do replacement in (haystack)
Push $R2 ; Replaced haystack
Push $R5 ; Len (needle)
Push $R6 ; len (haystack)
Push $R7 ; Scratch reg
StrCpy $R2 ""
StrLen $R5 $R3
StrLen $R6 $R1
loop:
StrCpy $R7 $R1 $R5
StrCmp $R7 $R3 found
StrCpy $R7 $R1 1 ; - optimization can be removed if U know len needle=1
StrCpy $R2 "$R2$R7"
StrCpy $R1 $R1 $R6 1
StrCmp $R1 "" done loop
found:
StrCpy $R2 "$R2$R4"
StrCpy $R1 $R1 $R6 $R5
StrCmp $R1 "" done loop
done:
StrCpy $R3 $R2
Pop $R7
Pop $R6
Pop $R5
Pop $R2
Pop $R1
Pop $R4
Exch $R3
FunctionEnd
HTH
matttiasw
6th October 2004 08:23 UTC
Check is Excel 2000 or later is installed
I need to make sure that Excel 2000 or later is installed. Excel 2000 is version 9.
I tried to following code
SearchPath $R2 "excel.exe"
MessageBox MB_OK|MB_ICONEXCLAMATION "Excel is at $R2"
GetDllVersion $R2 $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $0 "$R2.$R3.$R4.$R5"
MessageBox MB_OK|MB_ICONEXCLAMATION "Excel version is $0" IDOK AbortInstallation
Both with and without the initial SearchPath. I checked the version of the excel.exe file. It has something like 9.0.215
However, the message box above always prints 0.0.0.0 and SearchPath doesn't find excel.exe
What am I doing wrong?
---
An alternative implementation would be to check if
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Excel
exists and then if
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Excel
and then if
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Excel
However, there is no key at that level, so I cannot see how I can use ReadRegStr to check existence of the registry key.
matttiasw
6th October 2004 09:51 UTC
Kludge I will use sofar
It seems that Windows finds excel.exe even if it isn't part of the path. That is probably the reason SearchPath fails.
Instead I will use this code, but it probably won't work on non-English Excels:
StrCpy$0 "$PROGRAMFILES\Microsoft Office\OFFICE12\excel.exe"
IfFileExists $0 found_excel
StrCpy$0 "$PROGRAMFILES\Microsoft Office\OFFICE10\excel.exe"
IfFileExists $0 found_excel
StrCpy$0 "$PROGRAMFILES\Microsoft Office\OFFICE9\excel.exe"
IfFileExists $0 found_excel
StrCpy$0 "$PROGRAMFILES\Microsoft Office\OFFICE\excel.exe"
IfFileExists $0 found_excel
MessageBox MB_YESNO
|MB_ICONINFORMATION " I cannot find Excel 2000 or later.$\n$\n \
If you are sure you have a modern Excel and want to continue$\ninstallation anyway, press Yes."
IDYES excel_version_is_ok
IDNO AbortInstallation
found_excel:
GetDllVersion $0 $R0 $R1
IntOp $R2 $R0/ 0x00010000
IntOp $R3 $R0& 0x0000FFFF
IntOp $R4 $R1/ 0x00010000
IntOp $R5 $R1& 0x0000FFFF
StrCpy$0 "$R2.$R3.$R4.$R5"
;MessageBox MB_OK|MB_ICONEXCLAMATION "Excel version is $0" IDOK AbortInstallation
StrCmp $R2"9" excel_version_is_ok
StrCmp $R2"10" excel_version_is_ok
StrCmp $R2"11" excel_version_is_ok
StrCmp $R2"12" excel_version_is_ok
MessageBox MB_YESNO|MB_ICONINFORMATION " You are using Excel version $0, which is too old.$\n$\n \
If you are sure you have a modern Excel and want to continue$\ninstallation anyway, press Yes."
IDYES excel_version_is_ok
IDNO AbortInstallation
excel_version_is_ok:
matttiasw
6th October 2004 10:29 UTC
The path to excel.exe is found in the registry, so instead of the list above, the following code is much better:
ReadRegStr$0 HKLM "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\excel.exe" ""
IfFileExists $0 found_excel
MessageBox MB_YESNO
|MB_ICONINFORMATION " I cannot find Excel 2000 or later.$\n$\n \
If you are sure you have a Excel 2000 or later and want to continue$\n installation anyway, press Yes."
IDYES excel_version_is_ok
IDNO AbortInstallation
found_excel:
GetDllVersion $0 $R0 $R1
IntOp $R2 $R0/ 0x00010000
IntOp $R3 $R0& 0x0000FFFF
IntOp $R4 $R1/ 0x00010000
IntOp $R5 $R1& 0x0000FFFF
StrCpy$0 "$R2.$R3.$R4.$R5"
;MessageBox MB_OK|MB_ICONEXCLAMATION "Excel version is $0" IDOK AbortInstallation
StrCmp $R2"9" excel_version_is_ok
StrCmp $R2"10" excel_version_is_ok
StrCmp $R2"11" excel_version_is_ok
StrCmp $R2"12" excel_version_is_ok
MessageBox MB_YESNO|MB_ICONINFORMATION " You are using Excel version $0, which is too old.$\n$\n \
If you are sure you have a Excel 2000 or later and want to continue$\n installation anyway, press Yes."
IDYES excel_version_is_ok
IDNO AbortInstallation
excel_version_is_ok: