Archive: Help With Script


Help With Script
Hey,

Its my first time using Nsis, and im on a really tight timescale so im looking for all the help I can get.

I need to check if the .Net 2.0 Framework is installed and if not install it (i've tried the example script but I couldnt get it working). And then I need to check if MS SQL Express 2005 is installed and if not install it. Then comes the install of my app itself.

This is the script I have so far:

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "name"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "dsa"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\ReceptionApplication.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\ReceptionApplication.exe"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILES\name"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

Section "Reception Application" SEC01
SetOutPath "$INSTDIR\Data"
SetOverwrite try
File "Reception Application\Data\localDB.mdf"
File "Reception Application\Data\localDB_log.LDF"
;MORE FILES HERE
SectionEnd

Section "Service Tester" SEC02
File "Service Tester\PayTVDB.dll"
;MORE FILES HERE
SectionEnd

Section -AdditionalIcons
CreateShortCut "$SMPROGRAMS\STS PayTV Manager\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\ReceptionApplication.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\ReceptionApplication.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
WriteRegStr HKLM "Software\STS\System" "ABYPASS "AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAcCXyn0"
SectionEnd


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd

Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd

Section Uninstall
;LIST OF FILES
RMDir "$INSTDIR\Data"
RMDir "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd


I hope someone out there can help me out this rut?

Thanks In Advance!!!!
Chris

You can use this to check for .net 2.0

<code>
Function IsNetfx20Installed
${registry::Read} "HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727" "SP" $R0 $R1
${If} $R1 == ""
Push -1
${Else}
Push 0
${EndIf}
FunctionEnd
</code>

Then something like this to check for SQL Express and load it if necessary:
<code>
ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Microsoft SQL Native Client\CurrentVersion" "Version"
IfErrors 0 GOTSQL
DetailPrint "Beginning download of latest SQL Express."
NSISDL::download "http://pathtosqlinstaller" "$TEMP\SQLinstaller.exe"

DetailPrint "Completed download."
DetailPrint "Pausing installation while downloaded SQL Express installer runs."
ExecWait '$TEMP\SQLinstaller.exe /qb sapwd=password disablenetworkprotocols=0 securitymode=SQL INSTANCENAME=MSSQLSERVER ADDLOCAL=SQL_Engine'
DetailPrint "Completed SQL Express install. Removing SQL Express installer."
Delete "$TEMP\SQLinstaller.exe"
DetailPrint "SQL Express installer removed."
GOTSQL:
</code>