Archive: Reag Registry and then Execute a file


Reag Registry and then Execute a file
Hi...

i want to choose to setup java and/or OpenOffice. with "!insertmacro MUI_PAGE_COMPONENTS" i can show the sections.

But i want to read from the registry at first if its allready ,example Java, installed. And when its installen, then continue with the other installation, example OpenOffice.
But if java is not installed, then make the installation.

Can someone helps me????

This is a shortly version of my installer code:

;--------------------------------
;Include Ultra Modern UI

!include "UMUI.nsh"
!include "zipdll.nsh"

;--------------------------------
;General

;Name and File
Name "mediamid MediaServer"
OutFile "MediaServer-Setup_OC4J.exe"

;Default installation folder
InstallDir "$PROGRAMFILES\mediamid_MediaServer"

XPStyle on
CRCCheck on

;--------------------------------
;Functions

;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING

;--------------------------------
;Pages
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_PAGE_CUSTOMFUNCTION_SHOW WelSetTime
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "license.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_PAGE_CUSTOMFUNCTION_SHOW IFSetTime
!insertmacro MUI_PAGE_INSTFILES
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ISSetTime
!define MUI_PAGE_CUSTOMFUNCTION_PRE SetCheckbox
!insertmacro MUI_PAGE_FINISH
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ISSetTime
!insertmacro UMUI_PAGE_ABORT

;--------------------
;Nach der Installation wird WIndows-Dienst installiert
Function SetCheckbox
!define MUI_FINISHPAGE_RUN "$INSTDIR\wrapper\bin\Install_MediaServer.bat"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 1" "Type" "Label"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 1" "Text" "MediaServer wurde erfolgreich installiert!"

!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 2" "Type" "Label"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 2" "Text" "Bitte wählen Sie aus, ob MediaServer als Windows-Dienst installiert werden soll."
ExecWait "$INSTDIR\wrapper\bin\Install_MediaServer.bat"
MessageBox MB_OK "MediaServer wurde als Windows-Dienst installiert!"


FunctionEnd

;--------------------------------
;Ein Button beim license-Page
LicenseForceSelection radiobuttons


;--------------------------------
;Installer Sections

Icon "setup.ico"
UninstallIcon "uninstall.ico"
WindowIcon off



;Variablendefinition um aus der Registry zu lesen
Var /GLOBAL OOHOME
Var /GLOBAL JAVAJDK
Var /GLOBAL JAVAJRE

;Pfade aus der Registry herauslesen
ReadRegStr $OOHOME HKLM "SOFTWARE\OpenOffice.org\OpenOffice.org\2.0\{7C35B9AB-2CE3-4C18-BE7C-5B97EA089EB3}" "INSTALLLOCATION"
ReadRegStr $JAVAJDK HKLM "SOFTWARE\JavaSoft\Java Development Kit\1.5.0_02" "JavaHome"
ReadRegStr $JAVAJRE HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\1.5.0_02" "JavaHome"
# ReadRegStr $WASHOME HKLM '"SOFTWARE\IBM\Application Client for WebSphere Application Server\6.0\FJ2ee\Install"' "InstallLocation"


;--------------------------------
;Installer OpenOffice
Section "OpenOffice" SecOpenOffice
!insertmacro UMUI_LEFT_SETTIME 9
SetOverwrite on
SetOutPath "$INSTDIR"
File "OOo_2.0.3_Win32Intel_install_de.exe"
ExecWait '"$INSTDIR\OOo_2.0.3_Win32Intel_install_de.exe" "/Q"'
Delete "$INSTDIR\OOo_2.0.3_Win32Intel_install_de.exe"
MessageBox MB_OK "Die Installation von Open Office wurde beendet!"
Sleep 2000
goto next
next:

SectionEnd

;--------------------------------
;Installer Java
Section "Java 1.5.0_02" SecJava
!insertmacro UMUI_LEFT_SETTIME 5

SetOverwrite on
SetOutPath "$INSTDIR"

File "jdk-1_5_0_02-windows-i586-p.exe"
ExecWait '"$INSTDIR\jdk-1_5_0_02-windows-i586-p.exe" "/Q"'
Delete "$INSTDIR\jdk-1_5_0_02-windows-i586-p.exe"
MessageBox MB_OK "Die Installation von Java wurde beendet!"
Sleep 1000
goto next2
next2:
SectionEnd




;--------------------------------
;Installer MediaServer
Section "Programmdateien" SecMediaServer
;Noch 2 Minuten
!insertmacro UMUI_LEFT_SETTIME 2


;Muss ausgewählt sein
SectionIn RO

;Installation
SetOverwrite on
SetOutPath $INSTDIR

File mediaserver.jar
File ms.properties
File ms_oc4j.bat
# File ms_was.bat
File log4j.xml
File build.xml
Sectionend


Put the registry reading code in the section, compare the values to the expected values and jump to the end of the section, if Java shouldn't be installed.