Archive: Crash at end of install


Crash at end of install
  Hallo,

i've got an oddly problem. At the end of the install I get everytime an error message that my exe file could not be written, but it is!

Here is my nsi file:

Name "foo"
OutFile "killme.exe"
InstallDir "C:\foo"

!include "MUI2.nsh"

!insertmacro MUI_PAGE_LICENSE "license.rtf"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW SkipOnCond
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_PAGE_CUSTOMFUNCTION_SHOW SkipOnCond
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\notepad.exe"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Function SkipOnCond
; some true condition...
SendMessage $HWNDPARENT ${WM_COMMAND} 1 0 ; that should emulate a click on the next button
FunctionEnd

Section ""
SetOutPath $INSTDIR
File C:\Windows\system32\notepad.exe
WriteUninstaller $INSTDIR\uninstall.exe
SectionEnd

Section "Uninstall"
Delete "$INSTDIR\*.*"
RMDir "$INSTDIR"
SectionEnd

Your SkipOnCond function should be


GetDlgItem $0 $HWNDPARENT 1 
SendMessage $HWNDPARENT ${WM_COMMAND} 1 $0
>
BTW, using RMDIR "$INSTDIR" is potentially dangerous:
http://nsis.sourceforge.net/Validating_$INSTDIR_before_uninstall

Thanks good to know. I'm a nsis newbe :)

But my installer still crashes with the same error... more ideas?


Sorry for my bad info, made a mistake.

I'm not sure what the problem is, but somehow the UI is not fully initialized after a SHOW callback (try a sleep in the SHOW callback function), and somehow this causes the SkipOnCond function to be called 3 times in a row (try a MessageBox in the function).

To get the functionality you want, use a PRE callback instead, and call Abort:


Name "foo"
OutFile "killme.exe"
InstallDir "C:\foo"

!include "MUI2.nsh"

!insertmacro MUI_PAGE_LICENSE "license.rtf"
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipOnCond
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipOnCond
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\notepad.exe"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Function SkipOnCond
; some true condition...
Abort
FunctionEnd

Section ""
SetOutPath $INSTDIR
File C:Windowssystem32notepad.exe
WriteUninstaller $INSTDIRuninstall.exe
SectionEnd

Section "Uninstall"
Delete "$INSTDIR\*.*"
RMDir "$INSTDIR"
SectionEnd
>

Perfect! That works fine. :D

Thank you very much.