Someone123
1st August 2010 17:14 UTC
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
jpderuiter
1st August 2010 22:48 UTC
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
Someone123
2nd August 2010 00:32 UTC
Thanks good to know. I'm a nsis newbe :)
But my installer still crashes with the same error... more ideas?
jpderuiter
2nd August 2010 01:47 UTC
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
>
Someone123
2nd August 2010 09:35 UTC
Perfect! That works fine. :D
Thank you very much.