- NSIS Discussion
- Mui_page_directory
Archive: Mui_page_directory
AstraS
14th April 2007 14:34 UTC
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!
kichik
14th April 2007 14:44 UTC
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.
AstraS
14th April 2007 15:53 UTC
thx very mach!
and what to do?
how about number 2 question?
kichik
14th April 2007 15:58 UTC
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.
AstraS
14th April 2007 16:14 UTC
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!
AstraS
14th April 2007 16:16 UTC
PS and how connect 1 section to 1 directory page?
sorry for so many questions
kichik
14th April 2007 16:35 UTC
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
AstraS
18th April 2007 21:28 UTC
how can i change install path in directory page if before then i set MUI_DIRECTORYPAGE_VARIABLE
kichik
19th April 2007 19:04 UTC
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
AstraS
19th April 2007 21:57 UTC
:( it is not worked
kichik
19th April 2007 22:03 UTC
What exactly didn't work? What exactly did you do? I can't help you without any details.
AstraS
19th April 2007 22:03 UTC
function .oninit start before then i get $test_val, because
$test_val i can get, after installer setup firebird
kichik
19th April 2007 22:06 UTC
Then set it once you get it, as long as it's set before the directory page that uses it shows.
AstraS
20th April 2007 12:45 UTC
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?
kichik
20th April 2007 12:54 UTC
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.
AstraS
22nd April 2007 11:33 UTC
Is someone know, how change MUI_DIRECTORYPAGE_VARIABLE from
MUI_PAGE_DIRECTORY .
thx
Comperio
22nd April 2007 19:26 UTC
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:
AstraS
22nd April 2007 20:02 UTC
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
>
AstraS
22nd April 2007 20:04 UTC
please, try to use my code.
maybe it is error there
Comperio
22nd April 2007 20:33 UTC
Well, right off the bat, I see some syntax errors with your use (or lack of) the backslash character:
Examples:
- You set INSTDIR at the beginning to $PROGRAMFILESBB2. There is no such variable. You probably mean to use "$PROGRAMFILES\BB2"
- Delete $INSTDIRFirebird-1.5.3.4870-0-Win32.exe should be:
Delete $INSTDIR\Firebird-1.5.3.4870-0-Win32.exe
- 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)
- 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.)
AstraS
22nd April 2007 20:48 UTC
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???????????????????????
Comperio
22nd April 2007 21:21 UTC
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)
kichik
22nd April 2007 21:54 UTC
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.
AstraS
22nd April 2007 22:16 UTC
please show me how to do it.
thx
kichik
22nd April 2007 22:19 UTC
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?
AstraS
22nd April 2007 22:23 UTC
yes. i want move File "B2.FDB" to user input path
kichik
23rd April 2007 13:33 UTC
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
AstraS
23rd April 2007 19:47 UTC
no!
i setup firebird in my installer, after .oninit.
Comperio
24th April 2007 03:13 UTC
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.
AstraS
24th April 2007 11:53 UTC
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 ?
kichik
24th April 2007 12:33 UTC
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.
AstraS
24th April 2007 13:08 UTC
thx all!!!!!!!!!!!!!!!!!!!!!!
I do it!
If it is interesting i'll show it there.(its Comperio
variant whith some changes)
thx all!!!!