- NSIS Discussion
- Install Directory
Archive: Install Directory
treaz
18th February 2003 21:18 UTC
Install Directory
Hi,
I was thinking if it is possible for me to prevent the user from entering a destination directory that has spaces in them (e.g "C:\test folder\my test").
I am currently using the modern UI for its interface......can anyone help?
Thanks a lot.
:(
Joel
18th February 2003 21:20 UTC
there is a cool string functions in the archive:
http://nsis.sourceforge.net/archive/...instances=0,11
kichik
19th February 2003 15:42 UTC
And you can use that function in .onVerifyInstDir to find out if there is a space in $INSTDIR. If there is you can use Abort in this callback function to gray out the next button. If you want a message box too you'll have to do this check in the page's leave function.
Why don't you want the user to use spaces? Maybe there is a better way to do what you're looking for. If you are looking for valid DOS names for example (8.3) then you can use GetFullPathName /SHORT.
treaz
25th February 2003 22:52 UTC
Hi,
Thanks for the responses.
I do not wish to have spaces in the install directory because my program does not handle it. Guess I should try to modify my program instead but a temporary solution would be to make sure the user does not enter spaces.
How would you suggest I check for spaces and how can I use Abort such that the next button is grayed out?
Part 2:
Another different question:
Would I be able to disable the install directory page or in any case disable any pages while the program is running?
Purpose of this:
I wish to run a checking which would tell me if my program has already been installed once by the user and if it has been installed before, now I wish to run an update which will not require the user to select any destination directory. Destination directory would be read from the registry.
Thanks in advance for any sound advice.
:)
Joel
25th February 2003 23:27 UTC
For disable the Install Directory you can use:
DirShow hide ;normal nsis
or:
Don't put the !define MUI_DIRECTORYPAGE in Modern UI
Would I be able to disable the install directory page or in any case disable any pages while the program is running?
Maybe the
Callback Functions could help you.
deguix
26th February 2003 06:34 UTC
I was thinking if it is possible for me to prevent the user from entering a destination directory that has spaces in them (e.g "C:\test folder\my test").
Yes, it is possible. This code will disable the Install button if the path contains spaces. Uses "Search in a String" Function (or StrStr Function) :
Function .onVerifyInstDir
Push "$INSTDIR"
Push " "
Call StrStr
Pop $0
StrCpy $0 $0 1
StrCmp $0 " " 0 +2
Abort
FunctionEnd
(this code as been tested before posting)
Would I be able to disable the install directory page or in any case disable any pages while the program is running?
You can do this:
!define MUI_DIRECTORYPAGE
!define MUI_CUSTOMFUNCTION_DIRECTORY_PRE "Abort"
Function Abort
Abort
FunctionEnd
You can put the code for detect if is an update in this function abort.
kichik
26th February 2003 10:40 UTC
Why don't you want the user to use spaces? Maybe there is a better way to do what you're looking for. If you are looking for valid DOS names for example (8.3) then you can use GetFullPathName /SHORT.
I forgot to mention that valid DOS names have no spaces in them and they can be used as any other path names by Windows or any other program.
treaz
26th February 2003 16:50 UTC
You can do this:
!define MUI_DIRECTORYPAGE
!define MUI_CUSTOMFUNCTION_DIRECTORY_PRE "Abort"
Function Abort
Abort
FunctionEnd
I got a warning upon compiling the above:
install function "Abort" not referenced - zeroing code (777-778) out
When I ran the installer it does not disable the directory page too.
I guess I would need assistance on where I should place the above code. Or do I need to specify anything else like the page order?
My guess is may be my System.nsh file does not have this CustomFunction_Directory_Pre function.
Thanks. :)
treaz
26th February 2003 17:08 UTC
Originally posted by kichik
I forgot to mention that valid DOS names have no spaces in them and they can be used as any other path names by Windows or any other program.
I would very much prefer to use spaces too. However, at this point of time it's my program's incapability to use spaces not the installer. So for the time being I think I am better off not allowing spaces.
:p
treaz
26th February 2003 18:54 UTC
Looks like I found out that I need to use the Modern UI v1.6.2 or NSISv2.0b0.
May I know if I could also choose to disable the start-menu page during running check?
Thanks.
:)
kichik
26th February 2003 22:46 UTC
Indeed, you need the latest version for that (2.0b2).
What I meant with the short (DOS) file path names (hopefully it will come out clearer now :)) is that the installer can generate a path name with no spaces from any path name, with, or without spaces, for your programs use and it refer to the exact same file/dir as the long path with the spaces in it.
Just use:
GetFullPathName /SHORT $INSTDIR $INSTDIR
>
before you let your program know what $INSTDIR is. You'll get a name without spaces that works
exactly the same as the name with the spaces.
treaz
26th February 2003 22:57 UTC
Guess I finally get what you mean! Thanks. Looks like it's a good option out.
May I know if v2.0b2 supports disabling the StartMenu during installation?
Thanks.
:)
kichik
26th February 2003 23:02 UTC
I'll have to wait for Joost to reply on this one as he knows far more about the MUI than me. I have looked a bit on the source and couldn't find anyway to do it directly with the MUI but I might be wrong so it'll be better to wait for him
deguix
27th February 2003 07:56 UTC
Originally posted by treaz
Guess I finally get what you mean! Thanks. Looks like it's a good option out.
May I know if v2.0b2 supports disabling the StartMenu during installation?
Thanks.
:)
Yes! But have a documentation error: is MUI_CUSTOMFUNCTION_START not MUI_CUSTOMFUNCTION_STARTMENU. See how to do:
define MUI_DIRECTORYPAGE
>!define MUI_CUSTOMFUNCTION_DIRECTORY_PRE "Abort"
>!define MUI_STARTMENUPAGE
>!define MUI_CUSTOMFUNCTION_START "Abort"
>Function "Abort"
>Abort
FunctionEnd
>
View that MUI_CUSTOMFUNCTION_DIRECTORY_PRE and MUI_CUSTOMFUNCTION_START are using the same function.
Joost Verburg
27th February 2003 13:59 UTC
It should be MUI_CUSTOMFUNCTION_STARTMENU. Fixed in CVS.
treaz
27th February 2003 15:14 UTC
Hi,
Thanks for your respond. However, could you please advice me on how I should go about update my NSIS that I have installed to accomodate the changes you have made?
I just had v2.0b2 installed on my machine but it does not perform MUI_CUSTOMFUNCTION_START neither does it perform MUI_CUSTOMFUNCTION_STARTMENU.
Thanks. :)
Joost Verburg
27th February 2003 21:32 UTC
The current funtion is being called after calling the StartMenu plugin. I'll add a pre and leave funtion, so you can use the pre function :)
edit:
Done! Grab the latest CVS version. Define names have been changed, check the new StartMenu.nsi example.