Archive: Mui_page_directory


Mui_page_directory
  I have a problems.

1. in my installer i setup my files and Firebird.
First i use ExecWait tu setup firebird. After then i show
MUI_PAGE_DIRECTORY and add path of Firebird there.


  !insertmacro MUI_PAGE_INSTFILES

!define MUI_DIRECTORYPAGE_VARIABLE $test_val
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_FINISH
>..................some code cut..........................

>Section "Main Section" SecMain

>.............some code cut.....................

ReadRegStr $test_val HKLM "Software\Firebird Project\Firebird Server\Instances""DefaultInstance"
StrCmp $test_val "" "" +2
StrCpy $test_val "C:\Program Files\Firebird\"
StrCpy $1 $test_val

StrCpy $2 "
Data"
StrCpy "$test_val" "$1$2"

SetOutPath "$test_val"

File "B2.FDB"
SectionEnd
>
this code serching path of Firebird and write it into Directory page path field.
When user change path in this field installer copy file not in new path, it use old path ($test_val).

2. How can i change value (space required) on directory page ?
Thanks!

Sections are executed in the INSTFILES page. Therefore, whatever changes you make to $test_val after the INSTFILES page will not affect anything run in sections.


thx very mach!
and what to do?
how about number 2 question?


That's a sum of the size required by each selected section. To change the size required by a section, use AddSize or SectionSetSize on runtime.


thx again.
and how use 2 directory page? show different path in each of them, and different free space requirement and diferent files install?
thanks!


PS and how connect 1 section to 1 directory page?
sorry for so many questions


To show a different path, use MUI_DIRECTORYPAGE_VARIABLE as you already have and modify that variable so it's different than $INSTDIR.

To handle the required space, you must unselect all of the sections you don't want installed before showing the directory page. This way, their size won't be in the sum and they won't be executed. See the following example.

http://nsis.sourceforge.net/Two_inst..._one_installer


how can i change install path in directory page if before then i set MUI_DIRECTORYPAGE_VARIABLE


Change the variable that you pass on to MUI_DIRECTORY_VARIABLE. In your example, it should be:

Function .onInit
StrCpy $test_val $PROGRAMFILES\Test
FunctionEnd

:( it is not worked


What exactly didn't work? What exactly did you do? I can't help you without any details.


function .oninit start before then i get $test_val, because
$test_val i can get, after installer setup firebird


Then set it once you get it, as long as it's set before the directory page that uses it shows.


thx, i did it( for example i setup before directory page c:\Firebird\data), but if user change path in directory page (for example d:\temp\), installer put my file .....
into c:\Firebird\data anyway. :cry:
how can i do it?


If it put the file in that directory, you told it to put it there. Try following the logic of your installer with message boxes so you see exactly when everything is executed. For example, add a message box saying "installing into test_val $test_val" and you'll see where and when it copies the files there.

Also read the tutorial for details about how everything works together. Pay special attention to Script Execution.


Is someone know, how change MUI_DIRECTORYPAGE_VARIABLE from
MUI_PAGE_DIRECTORY .
thx


This is in the MUI documentation:
Just insert !define MUI_DIRECTORYPAGE_VARIABLE $yourvariable just before you add the page.

Take some time to read through the rest of the MUI documentation included with NSIS. And see Kichik's last reply.

There is a lot of good info out there--you just have to reach out and grab it. :up:


I read it, i use logic whith MessageBox, but i dont understend how chenge the path


;--------------------------------

;Include Modern UI
!include "MUI.nsh"
>;--------------------------------
;General
XPStyle on
;Name and file
Name "B2"
OutFile "setup.exe"
;Default installation folder
InstallDir "$PROGRAMFILES\B\B2"
>;--------------------------------
;Interface Settings

!define MUI_ABORTWARNING
>;--------------------------------

Var test_val

>;Pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
!insertmacro MUI_PAGE_INSTFILES
!define MUI_DIRECTORYPAGE_VARIABLE $test_val
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_FINISH

>;--------------------------------
>Section "Dummy Section" SecDummy

SetOutPath "$INSTDIR"
File "Firebird-1.5.3.4870-0-Win32.exe"

Delete $INSTDIRFirebird-1.5.3.4870-0-Win32.exe
RMDir $INSTDIR

ReadRegStr $test_val HKLM "Software\Firebird Project\Firebird Server\Instances""DefaultInstance"
StrCmp $test_val "" "" +2
StrCpy $test_val "C:\Program Files\Firebird\"
StrCpy $1 $test_val

StrCpy $2 "
Data"
StrCpy "$test_val" "$1$2"
StrCpy $INSTDIR "$test_val"

File "B2.FDB"

SectionEnd


;--------------------------------
;Installer Functions

Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY

FunctionEnd
>

please, try to use my code.
maybe it is error there


Well, right off the bat, I see some syntax errors with your use (or lack of) the backslash character:

Examples:

  1. You set INSTDIR at the beginning to $PROGRAMFILESBB2. There is no such variable. You probably mean to use "$PROGRAMFILES\BB2"
  2. Delete $INSTDIRFirebird-1.5.3.4870-0-Win32.exe should be:
    Delete $INSTDIR\Firebird-1.5.3.4870-0-Win32.exe
  3. ReadRegStr $test_val HKLM "SoftwareFirebird ProjectFirebird ServerInstances""DefaultInstance" should use this syntax:
    ReadRegStr $test_val HKLM "Software\Firebird ProjectFirebird ServerInstances""DefaultInstance"
    (I'm not sure the full registry path here, so you may need other \ characters in your path)
  4. StrCpy $test_val "C:Program FilesFirebird\" should be
    StrCpy $test_val "C:\Program Files\Firebird\"
    (note: you might not need the trailing backslash here, depending on what you trying to acomplish.)
Other than that, I think your code looks ok. (or if anything, it should get you a bit further.)

Comperio
thx, but it is not syntax error(that errors appear when i insert my code in forum- message), it is logical error.
Becauese, when appeare MUI_PAGE_DIRECTORY it is use path from MUI_DIRECTORYPAGE_VARIABLE (it is equal $test_val)
BUT WHEN USER CHANGING PATH, AND NEW PATH APPEAR IN PATH-LINE ON PAGE, installer use old path (it is equal $test_val)
why???????????????????????


Sorry, I didn't realize using [php] stripped the backslashes... (I guess this shows that [code] should be used instead of [php] in the forums when dealing with NSIS code.)

So back to your question:
Do you expect something to happen execute after MUI_PAGE_DIRECTORY? If so, you need to add a function for that.

Since you already used the sections when you inserted MUI_PAGE_INSTFILES, you'll have to execute the 2nd part using a leave function (which you can define with MUI_PAGE_CUSTOMFUNCTION_LEAVE)


Where in that example do you use $test_val beyond the directory page? It's set in the sections, displayed and modified by the directory page and then ignored.


please show me how to do it.
thx


That strictly depends on what you actually want to do. You let the user modify $test_val and then do nothing with it. What do you want to do with it?


yes. i want move File "B2.FDB" to user input path


Then why is the directory page after the instfiles page where the copy itself is made? If it's only for that ReadRegStr, put it in .onInit.

Function .onInit
ReadRegStr $test_val HKLM \
"Software\Firebird Project\Firebird Server\Instances" \
"DefaultInstance"
FunctionEnd

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "license.txt"
!define MUI_DIRECTORYPAGE_VARIABLE $test_val
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

no!
i setup firebird in my installer, after .oninit.


If it's just the one file you want to copy, then I'd try this: First, remove this code from the end of your section:


StrCpy $INSTDIR "$test_val"

then try this:


;Pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}DocsModern UILicense.txt"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_DIRECTORYPAGE_VARIABLE $test_val
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE MoveFile
!insertmacro MUI_PAGE_DIRECTORY

!insertmacro MUI_PAGE_FINISH

Section
... your original section code here...
SectionEnd

Function MoveFile
; I asume these paths are correct. If not you may need to modify...
Rename "$INSTDIR\B2.FDB" "$test_val\B2.FDB"
FunctionEnd


Or, if the FDB file is large and you want to see some progress, you could use the CopyFiles function to copy the file and then delete the file in the original location.

Comperio, thx but no, i show a part of code. i cann't do your variant.
Maybe someone know how move only some file to place in path string ?


You can have your installer gather all of the required installation details for Firebird and pass them on to their installer.

ExecWait '$PLUGINSDIR\FirebirdSetup.exe /DIR="$test_val" \
/SP /VERYSILENT /NORESTART'
This way, you can show the directory page before the instfiles page and know exactly what the Firebird installer did.

thx all!!!!!!!!!!!!!!!!!!!!!!
I do it!
If it is interesting i'll show it there.(its Comperio
variant whith some changes)
thx all!!!!