Archive: MUI installer initial directory & other queries


MUI installer initial directory & other queries
Hi there, im new to all this. (a.k.a being a cabbage :igor: )
Im using the MUI installer, What im trying to do is use the installer to copy a bunch of files to the users selected directory.

The problem with this is that I want the installer to look in the directory it is in and copy the files from there to the chosen destination folder.

What i have so far is:

;Installer Sections

Section "jag.exe" SecCopyUI

;Add your stuff here

SectionIn RO
SetOutPath "$INSTDIR"
File "C:\jag.exe"
File "C:\readme.txt"

So obviously the installer can only copy the files if they are in the C:\ root firectory. Could someone tell me what the command is for it to use the directory the installer is located in?

Also for the MUI_FINISHPAGE I want to add an extra check box option in addition to "Run program"that will have "View Readme".

How do I do this? Yes I know that this must be blatantly obvious, but some simple steps on how to do so would be great please.

Thanks in advance for trying to help a hopeless newbie.


* Add a directory page, use InstallDir and in the section, use SetOutPath.

* A finish page 'Show Readme' option is available. Please see the Modern UI Readme.


Wow, thanks for the prompt reply!
Okay let me see if im getting this right, but doesnt SetOutPath refer to the path that the user chooses for the installation files?
This is the code I have:
;Configuration

;General
OutFile "JAG-Installer.exe"

;Folder selection page
InstallDir "$PROGRAMFILES\${MUI_PRODUCT}"

;Remember install folder
InstallDirRegKey HKCU "Software\${MUI_PRODUCT}" ""

Because I need the command that will tell the installer to look in the directory its being run for the files that it has to copy. If im wrong,would the code look like this?


InstallDir "SetOutPath"

Thanks for the help with the readme, I thought that I would have to manually insert a check box and what not in the ini file. That would have been a mission. Thanks for your help Joost


To get the directory the installer resides in use $EXEDIR. This variable is a runtime variable, which means it will only have a value on runtime.

SetOutPath is a command that sets $OUTDIR (and creates the directory if needed). $OUTDIR is the directory files will be extracted to using the File instruction, unless /oname was used and then the path specified there will be used. Therefore, InstallDir "SetOutPath" isn't what you're looking for. It will in fact result in an empty $INSTDIR.

If you want to copy files from the installer's directory (for example, if the installer is on a CD along with some other files) use something like this:

CopyFiles $EXEDIR\myFile.dat $INSTDIR

This will copy myFile to the installation directory chosen by the user (if you used a directory page) or the default directory if the user chose not to change the installation directory or you didn't use a directory selection page.

If you want to compress files from the directory the script is into the installer you don't have to use a full path. The working directory is automatically set to the directory in which the script is so you shouldn't worry about where it really is.


Thanks for that kichik. That was exactly what I was looking for.
Unfortuntely this has now caused another problem in MUI_DIRECTORYPAGE. It no longer shows a proper value for space required. It shows 0.0 kb.

Is there anyway to get it to read the entire directory that the install files are located, add up all the file sizes and display the total in the MUI_DIRECTORYPAGE for space required?

Thanks again for the invaluable help kichik :)


You can use AddSize or SectionGet/SetSize if you're using the latest CVS version. AddSize is a compile command. You'd probably want to write an external program that would create an include file with AddSize in it, according to the size it will calculate. You can execute this program using !system and then include the file using !include.


Okay ive decided to go with the SetSize command, since I know the size of the files and they're not really going to change.
Heres the question. What file is the present command for 'space required' located in? I had a look through the NSIS directory and subdirectories but couldn't find anything.

Just wanted to know so that I could just replace the present space command with SetSpace.


SectionGetSize and SectionSetSize are both runtime commands. If the file sizes are not going to change AddSize will be much simpler. If you know the size of the files just add a line such as this to the appropriate section:

AddSize 25984


Where does it go though? Its for the MUI_DIRECTORY page so where do i add it in? Can I just add it into the main .nsi file?


It goes in a section. The directory page calculates the sum of all selected sections and displays that. Here's an example:

Section "Install bla"
AddSize 4531
CopyFiles this.dat $INSTDIR
SectionEnd


You cannot imagine what a great help youve been kichik! If youre even in New Zealand give me a yell :)


Will do :)