View Single Post
Old 18th January 2011, 21:57   #1
hermiod
Junior Member
 
Join Date: Jan 2011
Posts: 2
Error in macro registry::KeyExists

I'm just getting started writing installer scripts and have hit a problem whereby I get the following error when performing a keyexists check using the registry plugin.

I've looked at all the samples I can find online and they all seem to match my code, I can't see why this is failing.

This is the error:

!insertmacro: registry::KeyExists
File: "Registry.dll"->"$PLUGINSDIR\Registry.dll" [compress] 8807/16384 bytes
Plugin Command: _KeyExists HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5\ENU
Usage: Pop $(user_var: output)
Error in macro registry::KeyExists on macroline 2
Error in script "M:\MyProgs\VS\Projects\APTimeSheet\installscript.nsi" on line 53 -- aborting creation process

and here is the full script:

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "AFD Timesheet"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "AFD"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\AFDTimeSheet.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"

!include "Registry.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "APTimeSheet\icons\main.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\AFDTimeSheet.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\AFD\Timesheet"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

Section -SETTINGS
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
SectionEnd

Section "SSCE Runtime" SEC01

${registry::KeyExists} 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5\ENU' $var

${If} $var == -1
File "M:\\ssce1\SSCERuntime_x86-ENU.msi"
ExecWait '"msiexec" /i "$INSTDIR\SSCERuntime_x86-ENU.msi" /passive'
Delete "$INSTDIR\SSCERuntime_x86-ENU.msi"
${EndIf}

SectionEnd

Section "AFD Timesheet" SEC02
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "APTimeSheet\bin\Release\AFDTimeSheet.exe"
CreateDirectory "$SMPROGRAMS\AFD Timesheet"
CreateShortCut "$SMPROGRAMS\AFD Timesheet\AFD Timesheet.lnk" "$INSTDIR\AFDTimeSheet.exe"
CreateShortCut "$DESKTOP\AFD Timesheet.lnk" "$INSTDIR\AFDTimeSheet.exe"
File "APTimeSheet\bin\Release\AFDTimeSheet.exe.config"
File "APTimeSheet\bin\Release\System.Data.SqlServerCe.dll"
SectionEnd

Section "Reports" SEC03
SetOutPath "$INSTDIR\reports"
SetOverwrite ifnewer
File "APTimeSheet\bin\Release\reports\AccountReport.rdlc"
File "APTimeSheet\bin\Release\reports\TimesheetReport.rdlc"
SectionEnd

;Section "Blank Database" SEC04
; IfFileExists "$INSTDIR\TimeSheet.sdf" end
; File "TimeSheet.sdf"
;SectionEnd

Section -AdditionalIcons
CreateShortCut "$SMPROGRAMS\AFD Timesheet\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\AFDTimeSheet.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\AFDTimeSheet.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
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)? The database file will not be deleted." IDYES +2
Abort
FunctionEnd

Section Uninstall
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\System.Data.SqlServerCe.dll"
Delete "$INSTDIR\AFDTimeSheet.exe"

Delete "$SMPROGRAMS\AFD Timesheet\Uninstall.lnk"
Delete "$DESKTOP\AFD Timesheet.lnk"
Delete "$SMPROGRAMS\AFD Timesheet\AFD Timesheet.lnk"

RMDir "$SMPROGRAMS\AFD Timesheet"
RMDir "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
hermiod is offline   Reply With Quote