Ron.Stordahl
10th September 2011 17:20 UTC
MUI_DIRECTORYPAGE symbolic path entry?
Using MUI_DIRECTORYPAGE_VARIABLE the user is offered an opportunity to enter an alternative path to the offered 'variable'.
I issue this page twice, the first for the location to install program files, and the second time for the destination for the application data files. This is essential for Vista and Windows 7 and valuable for prior OS versions.
The path the user enters must be a literal one, but what I would like to offer is something symbolic like %appdata%\BPQ32, which would then be expanded to the rather lengthy literal path.
Is this possible?
Ron.Stordahl
10th September 2011 17:38 UTC
To clarify. I would like to offer the user the opportunity to enter a symbolic path, such as %appdata%\"something".
Anders
10th September 2011 17:41 UTC
Use ExpandEnvStrings to expand the path (Note: You talk about installing to $programfiles so you are elevated and then %AppData% could expand to the wrong users AppData)
Ron.Stordahl
12th September 2011 22:42 UTC
I would use this in conjunction with MUI_PAGE_DIRECTORY. But after the user entered something that I would use ExpandEnvStrings to process I would need to reissue that page with the expanded strings for his approval or to try again.
So I would want to loop that page somehow until the user approved it.
Is that possible? I am aware of MUI_PAGE_CUSTOMFUNCTION_PRE, SHOW and LEAVE, but I am not aware of how the same page can be looped until approved.
MSG
13th September 2011 06:07 UTC
In the leave function, you could set the new, expanded string to the dirrequest field and then call abort. Obviously you'll need to add some If ElseIf logic to only call abort once, otherwise you're stuck on the page forever.
To set the new path, you'll need the HWND of the dirrequest field. To get it, use WinSpy++ to get the field's Control ID. (Start winspy++, drag the white square onto the dirrequest field of an installer's DIRECTORY page, it will show you the Control ID and other stuff.) Then use that Control ID as the item_id parameter for GetDlgItem.
FindWindow $1 "#32770" "" $HWNDPARENT
GetDlgItem $0 $1 0x3FB
${NSD_SetText} $0 "New Path"
Please see also: http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.14.6