Archive: how do I get dir from MUI_PAGE_DIRECTORY?


how do I get dir from MUI_PAGE_DIRECTORY?
I have the line

!insertmacro MUI_PAGE_DIRECTORY

but it does not seem to provide me with the directory variable it prompts for.
my only guess is it has something to do with MUI_DIRECTORYPAGE_VARIABLE
but I am unable to access this. I have tried all kinds of ways to initialize it on .onInit and failed (!define, StrCpy)

!define: "MUI_DIRECTORYPAGE_VARIABLE" already defined!
Error in script "setup2.nsi" on line 242 -- aborting creation process
which is the !define in the following .onInit fragment:

${If} ${RunningX64}
StrCpy $Dir_Wanted "$PROGRAMFILES64\${PRODUCT_NAME}"
!define MUI_DIRECTORYPAGE_VARIABLE "${Dir_Wanted}"
${Else}
StrCpy $Dir_Wanted "$PROGRAMFILES\${PRODUCT_NAME}"
!define MUI_DIRECTORYPAGE_VARIABLE "${Dir_Wanted}"
${EndIf}

!define's the only thing that doesn't error out. kinda. but I made this change and things don't work.
elsewhere in the top of the install section, I have
${If} ${RunningX64}
StrCpy $INSTDIR "${Dir_Wanted}"
${Else}
StrCpy $INSTDIR "${Dir_Wanted}"
${EndIf}
SetOutPath "$INSTDIR"


I wanted to initialize the mui directory page thing so it has a correct default, but also allow for user input to change that value, so I can get a different directory if the user chooses. but I am not having sucess. I also need to get that dir that came from the user. any pointers?

I tried changing the !define to
!insertmacro MUI_DEFAULT MUI_DIRECTORYPAGE_VARIABLE Dir_Wanted

but it caused
2 warnings:
unknown variable/constant "{Dir_Wanted}" detected, ignoring (setup2.nsi:109)
unknown variable/constant "{Dir_Wanted}" detected, ignoring (setup2.nsi:112)


thanks.

Originally posted by jmichae3
I wanted to initialize the mui directory page thing so it has a correct default, but also allow for user input to change that value, so I can get a different directory if the user chooses. but I am not having sucess. I also need to get that dir that came from the user. any pointers?
Function on.Init
${If} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCT_NAME}"
${Else}
StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCT_NAME}"
${EndIf}
FunctionEnd

That's all.

Note however that you should only put 64 bits applications in $PROGRAMFILES64. If your application is 32 bits, you should only use $PROGRAMFILES. On 64 bits Windows that will point to "Program Files (x86)" (which is for 32 bits applications), and on 32 bits windows that will point to "Program Files" (which is of course also for 32 bits applications).

hmm. my programs contain
- DOS
- 64-bit
- 32-bit
- perl maybe
but I only provide links to the appropriate executable and also set the working directory for that shortcut.

is there a reason why you said what you said? I would like to know the technical details. I read some things about the virtual store. but I don't understand that much about it.


I don't understand your questions in the context of your first post.

Can you explain clearly what exact behavior you want to get in your installer?


- I want the user to be able to get an input box that is initialized with the kiind of program files appropriate for the platform, with the ability of them to browse/change it to a different folder or just enter in the path, and me get the var/whatever that contains that directory so I can finish the installation, to that directory.

- other that using copyfiles, I don't know how I am going to get the files there, because NSIS by default seems to dump the contents of the installer files into INSTDIR (not sure where or how). I just wish I could redirect it.

so I have 2 things to solve.


I can post a pastebin url of the whole code if you want. it's 264 lines.

if I get something working that's cross-platform, I would be glad to get some help posting it in the nsis samples.


1: Use the code I showed you to set the $INSTDIR default according to the platform the installer is running on. Then use a normal DIRECTORY page to allow the user to change it.
2: Use SetOutPath to change the directory where files are extracted. Usually, you want to do
SetOutPath $INSTDIR
to set the output directory to whatever the user entered on the DIRECTORY page.


I get no icons except for the uninstaller

the code isn't compiling properly with 3.0a, doing weird stuff


Originally posted by jmichae3
I get no icons except for the uninstaller

the code isn't compiling properly with 3.0a, doing weird stuff
How is this related to MUI_PAGE_DIRECTORY?

If you think there is a problem with the alpha, post in the alpha thread (With a real description of the problem, compiler error message if any and some sample code)

problem solved, got the small problem of icons worked out, was going to wrong directory.
now installer seems to work correctly. thank you for your help. kudos.


I had thought that maybe I could post a sample installer script so others could benefit from something that's english and cross-platform on modern machines.

but I have no clue how. I am only semi-capable of wiki-coding. and I don't understand the structure of the NSIS site (and there's no sitemap that I remember).


I have one more big problem. now that MUI_PAGE_DIRECTORY has written the page to the registry in HKCU ... getting it out is another thing (ReadRegStr?), and what to do on failsafe?

or should I be using something in Uninstall section like a MUI !insertmacro?
clus helpful, thanks.
MUI is not my native language yet, because documentation is not quite that good.


not knowing what else to do, I decided to store/read from the registry. if there is a MUI way, I would like to know. the Uninstall section doesn't see my
Var /GLOBAL StartMenuFolder

and neither does the "dot" functions.

what good is no variables in a function?
this is in 3.0a1.
the message is:
d:\prj\pwdgen\pwdgen-2.11>"\prog\nsis\makensis" setup2.nsi
Processing config: d:\prog\nsis\nsisconf.nsh
Processing script file: "setup2.nsi" (ACP)
warning: unknown variable/constant "{StartMenuFolder}" detected, ignoring (setup2.nsi:316)
warning: unknown variable/constant "{StartMenuFolder}" detected, ignoring (setup2.nsi:317)

Processed 1 file, writing output (x86-ansi):

Output: "d:\prj\pwdgen\pwdgen-2.11\pwdgen-2.11-setup.exe"
Install: 9 pages (576 bytes), 1 section (2072 bytes), 600 instructions (16800 bytes), 1 string (46594 bytes), 1 language table (370
bytes).
Uninstall: 3 pages (192 bytes),
1 section (2072 bytes), 88 instructions (2464 bytes), 1 string (2052 bytes), 1 language table (254 bytes).
Datablock optimizer saved 15709 bytes (~0.4%).

Using bzip2 compression.

EXE header size: 50176 / 34816 bytes
Install code: 18332 / 65764 bytes
Install data: 3667985 / 10450240 bytes
Uninstall code+data: 18794 / 22802 bytes
CRC (0xE086BE3C): 4 / 4 bytes

Total size: 3755291 / 10573626 bytes (35.5%)

2 warnings:
unknown variable/constant "{StartMenuFolder}" detected, ignoring (setup2.nsi:316)
unknown variable/constant "{StartMenuFolder}" detected, ignoring (setup2.nsi:317)


I'm sure one of the MUI examples show you how to save/restore the startmenu folder...


it's MUI_STARTMENU_GETFOLDER was one of the things I wanted. but those have a page_id, I have no clue what that means, what I am supposed to feed into a page_id, and the MUI docs need much improvement, they are not a spec that describes possible values or gives semantics.


You create the id when you call MUI_PAGE_STARTMENU, it can be anything, only matters when you have multiple startmenu pages...


It's in the manual:
http://nsis.sourceforge.net/Docs/Mod...UI/Readme.html
Chapter 3:

You will need the page ID for the Start Menu folder page when using the Start Menu folder macros.
It means that when you want to use any of the MUI_STARTMENU_GETFOLDER macro
1) you'll have to create a Startmenu page:
http://forums.winamp.com/showthread.php?t=308752
2) you'll have to define the MUI_STARTMENUPAGE_REGISTRY_* defines and use the MUI_STARTMENU_WRITE_* macros
http://stackoverflow.com/questions/3...ng-as-expected

The StartMenu.nsi example is a working example.
That should get you started.