Archive: Install Options: Prompt for variable


Install Options: Prompt for variable
Please Help! :) I'm relatively new to NSIS site. I've searched the Forums and InstallOptions documentation to no avail.

Trying to prompt the user for the name of a remote computer
then use that "CompName" to build a path.

I' ve looked thru InstallOptions and can't figure it out.
I get that I need an INI file, that's fine... it's the instructions on how to get the custom page to display that are messing me up.

Can anyone provide some sample scripts? (not the same in NSIS documentation)

Here's what i'm trying to do...

Text box to type in ComputerName (example: SCC40234)
Hit NEXT
the users input is pasted into a path like:
\\SCC40234\c$\Windows\System32
and then 2 files are copied over.

DONE

Like I said, the examples in InstallOptions are confusing me, I've been trying to write this script for a week and get nothing but errors.

PLEAZ help! :cry:


In the INI file:


[Settings]
NumFields=1

[Field 1]
Type=text
Value=
State=Default Computer Name
Left=
Right=
Top=
Bottom=

In installer script:

Page Custom Pre Post
...
Function Pre
; init dialog
Pop $R0 ; hwnd to window
; show dialog
FunctionEnd

Function Post
ReadINIStr $R1 <ini file> "Field 1" "State"
; $R1 has the value of the computer name entered by user
FunctionEnd

I get a blank screen with a progress bar which has "Install" and "Cancel" buttons..but nothing else on it.
If I hit Install.. then I can see that it is trying to copy the files from the path but it's missing the $R1 string so of course the copy fails.

The custom page doesn't show up on the screen therefore NSID never pauses on the Custom page so the user can input the field
Here's my entire code.. I'm keeping it simple for right now, 'til I figure out what I'm doing wrong.....


Outfile Mapi.exe

Function .onInit

InitPluginsDir
File /oname=c:\mapi.ini mapi.ini

FunctionEnd


Page Custom Pre Post


Function Pre
; init dialog
Pop $R0 ; hwnd to window
; show dialog
InstallOptions::dialog c:\mapi.ini
FunctionEnd

Function Post
ReadINIStr $R1 mapi.ini "Field 1" "State"
; $R1 has the value of the computer name entered by user
FunctionEnd

Page instfiles

Section Copy
CopyFiles $SYSDIR\mapi.dll \\$R1\C$\windows\system32\mapi.dll
CopyFiles $SYSDIR\mapisrvr.exe \\$R1\c$\windows\system32\mapisrvr.exe
SectionEnd


I guess I just don't understand How the custom page system works.

Try doing:


...
Page Custom Pre Post
Page instfiles
...
Function .onInit
InitPluginsDir
SetOutPath "$PLUGINSDIR"
File "mapi.ini"
FunctionEnd
...
Function Pre
InstallOptions::dialog "$PLUGINSDIR\mapi.ini"
FunctionEnd
Function Post
; R1 should have the company name entered
ReadINIStr $R1 "$PLUGINSDIR\mapi.ini" "Field 1" "State"
...

OK.. I incoporated the code and NOW I get a dialog box..
I used

Right=-1
Top=0
Bottom=12


BUT...
the

ReadINIStr $R1 "$PLUGINSDIR\mapi.ini" "Field 1" "State"

Doesn't return the value of Field1

If I use MessageBox MB_OK "$R1" all I get is "Success"

If I refer to $R1 in a file path I get...
Copy to \\success\C$\windows\system32\mapi.dll
Copy failed

So I've made progress, I just can't tell why it is registering the field as "sucess" and not the actual value?

InstallOptions says this...
To get the input of the user, read the State value of a Field using ReadINIStr:

ReadINIStr $R0 "$PLUGINSDIR\test.ini" "Field 1" "State"
But obviosuly it's not that simple..there's something else to it..???

Make sure you use ReadINIStr in the leave function not the creation function.

Page Custom CreateFunc LeaveFunc

-Stu


Thanks Afrow :)

after using Create and Leave
and then removing an extra POP command

it's working fine now

Thanks Goldy1604 for your quick responses as well.
Sometimes I get such a quick response on these forums it's almost like Instant messaging. :)