Archive: Install Directory


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.
:(


there is a cool string functions in the archive:

http://nsis.sourceforge.net/archive/...instances=0,11


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.


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.
:)


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.

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.

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.

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. :)

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

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.
:)


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.

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.
:)


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


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.

It should be MUI_CUSTOMFUNCTION_STARTMENU. Fixed in CVS.


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. :)


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.