Old 5th January 2005, 20:30   #1
wbarthol
Junior Member
 
Join Date: Jan 2005
Posts: 3
Strange Behaviour with .onVerifyInstDir

I am writing an installer to replace an executable that already exists and to ensure the user chooses the correct directory I am using onVerifyInstDir to check that the executable to be replaced already exists.

However, although in the install directory browse popup the OK button enables and disables correctly, the Install button on the main dialog only enables if you choose the default install directory, if you choose an alternate directory that contains the executable to be replaced the Install button remains disabled.

Here is the entire script:
code:

Name "Uploader SP1"
OutFile "UploaderSP1.exe"

InstallDir $PROGRAMFILES\Uploader

Page directory
Page instfiles

Section ""
SetOutPath $INSTDIR
File "Uploader.exe"
SectionEnd

Function .onVerifyInstDir
IfFileExists $INSTDIR\Uploader.exe PathGood
Abort ;
PathGood:
FunctionEnd



Any suggestions on what I'm doing wrong?
wbarthol is offline   Reply With Quote
Old 5th January 2005, 21:05   #2
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
Try using quotes, like this:

IfFileExists "$INSTDIR\Uploader.exe" PathGood
pengyou is offline   Reply With Quote
Old 5th January 2005, 21:11   #3
wbarthol
Junior Member
 
Join Date: Jan 2005
Posts: 3
I have tried quoting everything and that didn't work. I just worked out what's happening:

$INSTDIR is $PROGRAMFILES\Uploader, if you then browse for a directory that contains Uploader.exe (for example C:\Test) the OK button in the Browse box is enabled but when you click OK instead of putting C:\Test in the directory text box it is putting C:\Test\Uploader, it is as if it is appending the static part of $INSTDIR. Is this a bug?
wbarthol is offline   Reply With Quote
Old 5th January 2005, 22:13   #4
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
Quote:
Is this a bug?
No, this is explainied in the Users Manual

http://nsis.sourceforge.net/Docs/Chapter4.html#4.8.1.21

Here is a relevant extract from that section:

"Note that the part of this string following the last \ will be used if the user selects 'browse', and may be appended back on to the string at install time (to disable this, end the directory with a \ (which will require the entire parameter to be enclosed with quotes)"
pengyou is offline   Reply With Quote
Old 5th January 2005, 22:18   #5
wbarthol
Junior Member
 
Join Date: Jan 2005
Posts: 3
Thanks, works a treat.
wbarthol is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump