Archive: InstallOptions: question on FileRequest control


InstallOptions: question on FileRequest control
Before I begin I'd like to thank Justin and Michael for their work on NSIS and InstallOptions. A warm thank you to all other contributors as well. :)

Both my questions are related to the FileRequest control available in InstallOptions.

1. The InstallOptions docs state:

MaxLen (optional) This should be set to a maximum of 260 for "FileRequest" and "DirRequest" controls.
May I ask why? ;) Is that the limit on path lengths? So I should *definitely* set MaxLen to 260 for all FileRequest controls then?

2. Is there any way to specify an initial directory for the FileRequest dialog box? It seems to default to starting up in whatever directory InstallOptions.exe is running from.

Thank you. :D

Text (optional) Specifies the caption of a label control, or the initial text for text and comboboxes. Will also specify the initial value for FileRequest and DirRequest controls.

Thanks kichik, but I know about that. ;)
That sets the initial text in the FileRequest box. I want to know if theres a way to set the initial directory in the file browse dialog box that the FileRequest control pops up.


Would you be able to do a SetOutPath to the correct location before loading Install Options, and then load it using a full path?

  SetOutPath $TEMP
File InstallOptions.exe
File InstallOptions.ini

; I want the FileRequest to start at C:\WINDOWS
SetOutPath C:\WINDOWS

WriteINIStr $TEMP\InstallOptions.ini Settings ParentWnd $HWNDPARENT
ExecWait "$TEMP\InstallOptions $TEMP\InstallOptions.ini"
This hasn't been tested, but I don't see why it wouldn't work!

Thank you very much petersa! :D

I was beginning to think no-one would answer me. I am going to go try your suggestion & get back to ya. :)


Hi all. :)

Peter, thanks for the suggestion, man. It was a great idea and it works well enough.

I did run into a problem, I think it might be a bug with NSIS1.67/InstallOptions, my computer, or my script. (I don't see anything wrong with the script though. :)

The problem is that certain variables don't work with the file browse box. (They seem to work fine everywhere else tho)

For example the following works, i.e. the file browse dialog box opens up at C:\Windows\

;copy installoptions.exe to temp dir
SetOutPath $TEMP
File InstallOptions.exe
File "filereq.ini"

;SetOutPath to folder you want browse file box to start at
SetOutPath "$WINDIR"
;run installoptions
WriteINIStr $TEMP\filereq.ini Settings ParentWnd $HWNDPARENT
ExecWait '$TEMP\InstallOptions $TEMP\filereq.ini'
ReadINIStr $1 $TEMP\filereq.ini Results 2
ReadINIStr $2 $TEMP\filereq.ini Results 4
But the following (which is what I wanted) doesn't work - the file browse box starts at the 'My Documents' folder:
;copy installoptions.exe to temp dir
SetOutPath $TEMP
File InstallOptions.exe
File "filereq.ini"

;SetOutPath to folder you want browse file box to start at
SetOutPath "$PROGRAMFILES"
;run installoptions
WriteINIStr $TEMP\filereq.ini Settings ParentWnd $HWNDPARENT
ExecWait '$TEMP\InstallOptions $TEMP\filereq.ini'
ReadINIStr $1 $TEMP\filereq.ini Results 2
ReadINIStr $2 $TEMP\filereq.ini Results 4
I have obtained the following results when using variables to set outpath for the file browse box:
SetOutPath "$QUICKLAUNCH" ;My Documents
SetOutPath "$INSTDIR" ;My Documents
SetOutPath "$PROGRAMFILES" ;My Documents
SetOutPath "$DESKTOP" ;My Documents
SetOutPath "$EXEDIR" ;Works
SetOutPath "$WINDIR" ;Works
SetOutPath "$SYSDIR" ;Works
SetOutPath "$TEMP" ;Works
SetOutPath "$STARTMENU" ;My Documents
SetOutPath "$SMPROGRAMS" ;Works
SetOutPath "$SMSTARTUP" ;My Documents
SetOutPath "$QUICKLAUNCH" ;My Documents
I have found that even if i write the path, e.g. SetoutPath "C:\Program Files" it doesn't work and insists on opening at My Documents.

And one final item I noticed is that the Details view of the install shows that the OutputDir is indeed being set correctly all the time, even if the file browse box opens at My Documents. This is a very strange bug.

I am attaching my code - it's very simple, it's a trimmed down version of the example that comes with InstallOptions. Included in the zip is a screenshot of the details view of the install.

I hope some kind souls out there will have a look at it, at least compile it and see if they get the same error on their system. :)

Thanks guys & gals. :eek:

I just tried it on my system with $PROGRAMFILES, and got My Documents. Sounds like a problem with Install Options.

I think I've found another bug with Install Options: after clicking the '...' button and then clicking 'Cancel', the box then re-opens, as if you had pressed the '...' button again.

Anyone else get this?

I think another option should be added to the INI file, like DefaultFolder or something, so that you don't have to set the working directory to it.

Actually, I think that $HWNDPARENT should be specified as a command line argument and not as part of the INI file, because it's an unnecessary write to the file that can be avoided.


I'm rather pleased (does this make me perverse? :p) to hear you experienced the same problem - at least this means the problem is reproducible and apparently identifiable.

Thanks again petersa, you're a one-man assistance machine. :)

I experienced the same click on '...', click on 'Cancel', file browse box reappears phenomenon. If I click 'Cancel' on the second box though, it really goes away. ;) You can't blame a module for being persistent. :)

Oh a 'DefaultFolder' option would be divine. I'm so grateful for what I already have, though. It's really kind of people like Justin, Michael, and all other contributors to NSIS (yourself included petersa) to work on NSIS and benefit so many others. :D


I will take a look at this and fix it ASAP. (btw, my cable connection is AWOL while @home sorts out their business. Until I get it back I may not post much)

The way it's supposed to work (at least in my mind) is to open in whatever directory is specified by the filename in the box. If this is empty (or invalid path) then it's going to use the current directory.

Anybody else agree/disagree with this operation?

michael


I agree with you there, but if there isn't a file in the box then a default directory would be good, instead of just 'My Documents', because chances are the file you're looking for won't be there.


hrmm, perhaps you are right. Allow the user to specify default directories for each control. It would use that after filename, but before the current directory.

michael


Sounds great. :D


I'll second that - it sounds great. :)

I can't *believe* I'm getting NSIS for free - incredible. :eek:


Unable to display filerequest control
Hi,
I am trying to add a file request to my ui...
but when I run the exe file it does not show the control....

I have the same problem with the dirrequest control...
this is my ini code:

; Auto-generated by EclipseNSIS InstallOptions Script Wizard
; May 13, 2013 10:51:19 AM
[Settings]
NumFields=2

[Field 1]
Type=FileRequest
Left=25
Top=93
Right=258
Bottom=106
Flags=NOTIFY|FILE_EXPLORER|FILE_MUST_EXIST|PROMPT_CREATE
MaxLen=260

[Field 2]
Type=DirRequest
Left=25
Top=62
Right=258
Bottom=75
Flags=NOTIFY
MaxLen=260


Thanks in advance...


This is only form definition, can you show some script how use this form?

I suggest you to switch to nsDialog, InstallOptions forms are deprecated.