Skip to content
⌘ NSIS Forum Archive

how to deny "goto next page"?

6 posts

orecchionebruno#

how to deny "goto next page"?

Hi to everyone, I read the help on line and NSIS site but I didn't find a solution for this problem. Someone have a suggestion for don't allow that install process could start?

My target is to update a file and user should choose right folder.

I tried with this script, but the result is that the installer will be closed if doesn't find right file. What I would is that the installer doesn't "Goto next page" untill user choose right folder. (at the startup installer reads Install path in the registry)

Function .onVerifyInstDir
IfFileExists "$INSTDIR\MyApp.exe" +3 0
MessageBox MB_OK "MyApp doesn't exist. Please select MyApp directory."
Abort
MoreInfo::GetProductVersion "$INSTDIR\MyApp.exe" ;get exe version (MoreInfo plug-in)
Pop $1
StrCmp $1 "3.1 " +3 0
MessageBox MB_OK "Invalid version!$\rPlease select MyApp directory."
Abort
FunctionEnd
Afrow UK#
This works fine for me (attached). Don't put any message boxes in there because it will spam the user multiple times.

Stu
orecchionebruno#
Hi Stu, thanksss for your help now I've found My mistake.

MY MISTAKE was in the "jump to line n.r X o Y" in the event "onInit" and I've leaved wrong and true strings:

Function .onInit
Processes::FindProcess "MyApp.exe"
StrCmp "$R0" "0" +3 0
Messagebox MB_OK "MyApp doesn't exist. Please select MyApp directory."
Abort
ReadRegStr $1 HKCR "MyApp\Path" ""
; IfFileExists "$1\MyApp.exe" 0 +3 ;!!!THIS STRING IS WRONG BEACAUSE NEXT IfFileExists SHOULD NOT BE PRESENTS TWO TIMES!!!!!!!!!!!
IfFileExists "$1\MyApp.exe" 0 +2 ;!!!THIS IS TRUE
StrCpy $INSTDIR "$1"
FunctionEnd

Ciao
Bruno

PS: in the orginal script I dint' wrote two IfFileExists commands so "+3" was wrong because goes directly to next event witout reading "FunctionEnd"
MSG#
orecchionebruno: I suggest you start using LogicLib to simplify your code. Instead of IfFileExists etcetc, you can do
${If} ${FileExists}
stuff here
${Else}
other stuff here
${EndIf}

And so on and so forth.