Archive: Adding input field to modern...


Adding input field to modern...
How would I go about adding an input field to the Modern installer? I'd like to be able to add a text field into my simple script (Generated by Venis), which would allow me to set a variable. Would anyone care to tell me a good place to start?


The easiest way (in my opinion) would be to create a custom page using InstallOptions. (See the InstallOptions docs included with the NSIS install.)

If you were really brave, you might be able to hack the MUI ressource files. (Something I've not been brave enough to try, but it is another option.)

If you need this special input field in either the welcome or finish page, you can insert code into the PRE function of the welcome or finish page to modify the ioSpecial.ini file. (This info comes from the MUI documentation also included with the main NSIS install.)
:D


Try InstallOptions or, as my best suggestion, move-on to HM Edit Nsis.


Thanks for the pointers, HMEdit's giving me an error right now... here's what I have:


Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "c:\wsus.ini" "wsus.ini"
FunctionEnd


Page custom WSUSPage

Function WSUSPage
!insertmacro MUI_HEADER_TEXT "WSUS Server..." "Stuff"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "wsus.ini"
!insertmacro MUI_INSTALLOPTIONS_READ $server "wsus.ini" "Field 1" "Text"
FunctionEnd


and it's giving me...

Function: "WSUSPage"
!insertmacro: MUI_HEADER_TEXT
!insertmacro: end of MUI_HEADER_TEXT
!insertmacro: MUI_INSTALLOPTIONS_DISPLAY
!insertmacro: end of MUI_INSTALLOPTIONS_DISPLAY
!insertmacro: MUI_INSTALLOPTIONS_READ
Usage: ReadINIStr $(user_var: output) ini_file section entry_name
Error in macro MUI_INSTALLOPTIONS_READ on macroline 5
Error in script "C:\Program Files\HMSoft\NIS Edit\wsus.nsi" on line 108 -- aborting creation process


Where my ini is:

; Ini file generated by the HM NIS Edit IO designer.
[Settings]
NumFields=2
Title=Setting our WSUS Server
NextButtonText=Next
BackButtonText=Previous

[Field 1]
Type=Text
State=Text
Left=54
Right=267
Top=28
Bottom=41

[Field 2]
Type=Label
Text=Server IP/Name
Left=0
Right=51
Top=30
Bottom=38

Did you declare the $server variable with Var server?

-Stu


Nope, and i noticed that later on. I decided to go ahead and use $R0 as other people had suggested in another thread and a messagebox popup to make sure it's passing the data. I still can't get it to pass the data properly...
Here's what I have now:


Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "c:\wsus.ini" "wsus.ini"
FunctionEnd

Page custom WSUSPage WSUSPageLeave

Function WSUSPage
!insertmacro MUI_HEADER_TEXT "WSUS Server..." "whee"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "wsus.ini"
ReadINIStr $R0 "wsus.ini" "Field 1" "State"
FunctionEnd

Function WSUSPageLeave
MessageBox MB_OK $R0
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" "WUServer" "http://$R0"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" "WUStatusServer" "http://$R0"
FunctionEnd

Seems like you'd want to read your InstallOptions ini file during the leave function instead of the show function. The MUI docs also state you can use MUI_INSTALLOPTIONS_READ from within a section (rather than a function).

In my personal experience, I've found it better to read during the leave function becuase it allows me to verify what the user entered and call an ABORT command if necessary. On the other hand, if the users makes his/her selection via a hard-coded choice--such as radio button or drop-down menu--then either method should work.


Data on the InstallOptions page is only written to the INI file after you leave the page Show function. Therefore, your INI file will remain unchanged until the Leave function is reached.

-Stu


Sorry for bumping this thread, but i had the same problem so i thought id post the solution.

You need to init the plugins folder in the .oninit function.
If you do this then you can use the MUI_INSTALLOPTIONS_READ macro within a function.

eg:
Function .onInit
InitPluginsDir
File /oname=$PLUGINSDIR\dcsdraft.ini MYINI.ini
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "MYINI.ini"
FunctionEnd

r,
vsleepy