Archive: Help me pick an installer example


Help me pick an installer example
I'm trying to build an installer that does the following. Are there any good examples out there? All I see is a sea of them.

1. Check and see if there was a prior installation, if so, allow install ontop, or uninstall the whole installation.
2. Ask for directory of installation
3. Ask some settings questions
4. Execute some file create, move, delete
5. Run another MUI page to determine some system settings and give the user option for input.
6. User enters serial code, we check it online.
7. Exit


bump


I don't think there's a standalone example with those tasks. I will try to help you.

1. To check you can try ReadRegStr to find registry entries of past installers.
2. Use Page directory, or build your own with InstallOptions or nsDialogs.
3. Again, build your pages with above pluigns.
4. Exec, ExecShell
5. ?
6. Again, build your page and use InetLoad.
7. Close.


We aren't using the registry whatsoever. I already have the inetload code we need. Now what I really need is an example installer that asks where the program should be installed, and perhaps has an extra page or uninstall function inside it.


Pretty much every installer out there asks for the installation directory. Starting from Examples\example1.nsi, through cool examples like primes.nsi ranging all the way to full blown examples on the Wiki. As Joel said, all you need is Page directory or MUI_PAGE_DIRECTORY.


I used some examples to patch together a rudimentary installer. Now I need to add a custom page and custom code i've already made up from another installer. Can anyone help me mate the code to my installer?

I've written some code that automatically checks for proxy information on the machine. It also allows the user to enter in HTTP and HTTPS proxy information, and later ask for a password when in use. I had an old ini page for it but made up a new one, since it needs much fewer options.

I am highly motivated to finish this in the next 24 hours, and I would be willing to compensate someone who is expert to take on the task themselves.


;--------------------------------
!include "MUI.nsh"
!define PROGRAM_NAME "Program"
!define PROGRAM_EXE "Program.exe"
!define INSTALLATION_DIR "$PROGRAMFILES\Program"
!define COMPANY_NAME "Company"
; The name of the installer
Name "${COMPANY_NAME}"

; The file to write
OutFile "${COMPANY_NAME}.exe"

; The default installation directory
CRCCheck on
InstallDir ${INSTALLATION_DIR}
ShowInstDetails show
LicenseText "${COMPANY_NAME} License Agreement"
LicenseData "license.txt"
XPStyle on

;--------------------------------

; Pages

Page license
Page directory
Page instfiles
;Modified Finish Page
!define MUI_PAGE_CUSTOMFUNCTION_PRE fin_pre
!define MUI_PAGE_CUSTOMFUNCTION_SHOW fin_show
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE fin_leave
!define MUI_FINISHPAGE_SHOWREADME "${NSISDIR}\Docs\Modern UI\Changelog.txt"
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION Desc_ShortCut
!define MUI_FINISHPAGE_RUN_TEXT "Create Desktop Shortcut"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English"



; The stuff to install
Section "" ;No components page, name is not important

SetOutPath $INSTDIR\temp ; temporarily set output path temp dir to extract the data.
File data.zip ;extract the data to install
ZipDLL::extractall "$INSTDIR\temp\data.zip" "$INSTDIR" ;extract all the files in data
SetOutPath $INSTDIR ; set output path temp dir to extract the data.
Delete "$INSTDIR\temp\data.zip"; remove the temp file once it was all installed.
RMDir "$INSTDIR\temp" ;remove the temp dir

SectionEnd ; end the section

;------------------
;Functions
Function Desc_Shortcut
SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\${PROGRAM_NAME}.lnk" "$INSTDIR\${PROGRAM_EXE}"
FunctionEnd

Function fin_show
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "HWND"
SetCtlColors $0 0x000000 0xFFFFFF
FunctionEnd

Function fin_pre
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Settings" "NumFields" "6"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Type" "CheckBox"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Text" "&Create Quicklaunch Shortcut"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Left" "120"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Right" "315"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Top" "130"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Bottom" "140"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "State" "1"
FunctionEnd

Function fin_leave
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "State"
StrCmp $0 "0" end
SetOutPath "$INSTDIR"
CreateShortCut "$QUICKLAUNCH\my program.lnk" "$INSTDIR\makensisw.exe"
end:
FunctionEnd


And this is the INI


Ini file generated by the HM NIS Edit IO designer.
[Settings]
NumFields=15
Title=XeroBank Configuration Wizard
CancelShow=1
CancelButtonText=&Cancel
NextButtonText=&Generate

[Field 1]
Type=Groupbox
Text=Internet Settings
Left=20
Right=260
Top=0
Bottom=68
Flags=NOTABSTOP

[Field 2]
Type=Groupbox
Text=Proxy Settings
Left=20
Right=260
Top=70
Bottom=140
Flags=NOTABSTOP|DISABLED

[Field 3]
Type=Label
Text=HTTP Proxy:
Left=32
Right=76
Top=86
Bottom=96
Flags=NOTABSTOP|DISABLED

[Field 4]
Type=Text
State=IP Address
Left=99
Right=171
Top=83
Bottom=96
MaxLen=256
Flags=DISABLED

[Field 5]
Type=Text
State=Port
Left=174
Right=201
Top=83
Bottom=96
MaxLen=5
Flags=DISABLED|ONLY_NUMBERS

[Field 6]
Type=Checkbox
Text=Requires Username && Password
Left=87
Right=204
Top=97
Bottom=109
Flags=DISABLED

[Field 7]
Type=Label
Text=HTTPS Proxy:
Left=32
Right=79
Top=113
Bottom=123
Flags=NOTABSTOP|DISABLED

[Field 8]
Type=Text
MaxLen=256
State=IP Address
Left=99
Right=171
Top=113
Bottom=124
Flags=DISABLED

[Field 9]
Type=Text
MaxLen=5
State=Port
Left=174
Right=202
Top=113
Bottom=124
Flags=DISABLED|ONLY_NUMBERS

[Field 10]
Type=Checkbox
Text=Requires Username && Password
Left=87
Right=202
Top=128
Bottom=137
Flags=DISABLED

[Field 11]
Type=Button
Text=Auto-Detect
Left=205
Right=255
Top=83
Bottom=136
Flags=DISABLED|NOTIFY

[Field 12]
Type=RadioButton
Text=Direct Connection
Left=44
Right=119
Top=32
Bottom=42

[Field 13]
Type=RadioButton
Text=Network Proxy
Left=44
Right=119
Top=48
Bottom=58

[Field 14]
Type=Label
Text=How do you connect to the internet?
Left=30
Right=146
Top=16
Bottom=24

[Field 15]
Type=Label
Text=(Most Users)
Flags=NOTABSTOP
Left=120
Right=159
Top=32
Bottom=40


And here is the old installer code we want to mate to this new INI and installer:


!include "MUI.nsh"

;---------------------
;includes
!include "LogicLib.nsh"
!include "WordFunc.nsh"
!insertmacro WordFind
!insertmacro WordFind2x
!insertmacro WordReplace

;----------------------
;MUI defines

!define BROWSERNAME "xBBrowser"
!define MAILCLIENTNAME "xBMail"
!define UIDISABLEWARNING "Field 2"
!define UIDISABLESPLASH "Field 3"
!define UIDISABLETOR "Field 4"
!define UIWAITFORCIRCUIT "Field 5"
!define UIPROXYREQ "Field 6"
!define UIDEBUGON "Field 7"

!define UITORBOX "Field 8"

!define UICIRCUITLABEL "Field 9"
!define UICONTROLLABEL "Field 11"
!define UISOCKSLABEL "Field 13"
!define UITORCOMLABEL "Field 15"

!define UITORTIMEOUT "Field 10"
!define UICONTROLPORT "Field 12"
!define UISOCKSPORT "Field 14"
!define UITORCOMMANDS "Field 16"
!define UIDELDIRDATA "Field 17"

!define UIIPADDRESS1 "Field 20"
!define UIPORT1 "Field 21"
!define UIREQAUTH1 "Field 22"

!define UIIPADDRESS2 "Field 24"
!define UIPORT2 "Field 25"
!define UIREQAUTH2 "Field 26"

!define UIAUTODETECT "Field 27"
!define UIHTTPLABEL "Field 19"
!define UIHTTPSLABEL "Field 23"


;--------------------------------
;General

;Name and file
!define NAME "xBConfig"
Name "XeroBank Configuration Wizard"
OutFile "xBConfig.exe"

;Default installation folder
InstallDir "$EXEDIR\.."

;Get installation folder from registry if available

;--------------------------------
;Pages

Page custom InitPage LeavePage

;--------------------------------
;Interface Settings

!define MUI_ABORTWARNING

;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Reserve Files

;If you are using solid compression, files that are required before
;the actual installation should be stored first in the data block,
;because this will make your installer start faster.

ReserveFile "xBConfig.ini"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

;--------------------------------
;Variables
Icon "${NAME}.ico"
VAR DISABLEWARNING
VAR DISABLESPLASH
VAR DISABLETOR
VAR WAITFORCIRCUIT
VAR DEBUGON

VAR TORTIMEOUT
VAR CONTROLPORT
VAR SOCKSPORT
VAR TORCOMMANDS
VAR DELDIRDATA

VAR IPADDRESS1
VAR PORT1
VAR REQAUTH1
VAR IPADDRESS2
VAR PORT2
VAR REQAUTH2
VAR PROXYREQ

VAR HTTPPROXY
VAR HTTPSPROXY




Var tmp
Var tmpstate ; holds the value of the state
Var tmpstate2
Var tmphwnd ; holds the hwnd of the element

;reads the hwnd from the ini file and sets the state of the element
!macro CHANGEELEMENT ELEMENT STATEVAL
!insertmacro MUI_INSTALLOPTIONS_READ $tmphwnd "xBConfig.ini" "${ELEMENT}" "HWND"
EnableWindow $tmphwnd ${STATEVAL}

; Put state change in flags of element as well
!insertmacro MUI_INSTALLOPTIONS_READ $tmp "xBConfig.ini" "${ELEMENT}" "Flags"
${If} "${STATEVAL}" == "1"
${WordReplace} $tmp "DISABLED" "" "+" $tmp
${WordReplace} $tmp "||" "|" "+" $tmp
!insertmacro MUI_INSTALLOPTIONS_WRITE "xBConfig.ini" "${ELEMENT}" "Flags" $tmp
${Else}
!insertmacro MUI_INSTALLOPTIONS_READ $tmp "xBConfig.ini" "${ELEMENT}" "Flags"
!insertmacro MUI_INSTALLOPTIONS_WRITE "xBConfig.ini" "${ELEMENT}" "Flags" "$tmp|DISABLED"
${EndIf}



!macroend

;change the state of a group of elements
!macro CHANGEGROUPSTATE STATEVALUE

!insertmacro CHANGEELEMENT "${UIIPADDRESS1}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UIPORT1}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UIREQAUTH1}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UIIPADDRESS2}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UIPORT2}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UIREQAUTH2}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UIAUTODETECT}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UIHTTPLABEL}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UIHTTPSLABEL}" "${STATEVALUE}"

!macroend

!macro CHANGEGROUPSTATE2 STATEVALUE
!insertmacro CHANGEELEMENT "${UITORTIMEOUT}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UISOCKSPORT}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UICONTROLPORT}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UICIRCUITLABEL}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UICONTROLLABEL}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UISOCKSLABEL}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UITORCOMLABEL}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UITORCOMMANDS}" "${STATEVALUE}"
!insertmacro CHANGEELEMENT "${UIDELDIRDATA}" "${STATEVALUE}"
!macroend

;change text field and put value in ini file
!macro CHANGETEXTFIELD ELEMENT VALUE
!insertmacro MUI_INSTALLOPTIONS_WRITE ${VALUE} "xBConfig.ini" "${ELEMENT}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $tmp "xBConfig.ini" "${ELEMENT}" "HWND"
SendMessage $tmp ${WM_SETTEXT} 0 "STR:${VALUE}"
!macroend

;--------------------------------
;Installer Sections

Section "Dummy Section" SecDummy

SetOutPath "$INSTDIR"

;ADD YOUR OWN FILES HERE...

;Store installation folder

SectionEnd

;--------------------------------
;Installer Functions

Function .onInit

;Extract InstallOptions INI files
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "xBConfig.ini"

FunctionEnd

LangString TEXT_IO_TITLE ${LANG_ENGLISH} "XeroBank Configuration Wizard"
LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "Generates XeroBank INI Files"

Function InitPage

!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "xBConfig.ini"

FunctionEnd

Function LeavePage
; handle notify event of element
!insertmacro MUI_INSTALLOPTIONS_READ $tmp "xBConfig.ini" "Settings" "State"
${Switch} "Field $tmp"
${Case} "${UIPROXYREQ}"
!insertmacro MUI_INSTALLOPTIONS_READ $tmpstate "xBConfig.ini" "${UIPROXYREQ}" "State"
!insertmacro CHANGEGROUPSTATE $tmpstate
Abort
${Case} "${UIAUTODETECT}"
Call GetProxySettings

;fill in ini-file and change text
!insertmacro CHANGETEXTFIELD "${UIIPADDRESS1}" "$IPADDRESS1"
!insertmacro CHANGETEXTFIELD "${UIPORT1}" "$PORT1"
!insertmacro CHANGETEXTFIELD "${UIIPADDRESS2}" "$IPADDRESS2"
!insertmacro CHANGETEXTFIELD "${UIPORT2}" "$PORT2"

!insertmacro MUI_INSTALLOPTIONS_WRITE $IPADDRESS1 "xBConfig.ini" "${UIIPADDRESS1}" "State"
!insertmacro MUI_INSTALLOPTIONS_WRITE $PORT1 "xBConfig.ini" "${UIPORT1}" "State"
!insertmacro MUI_INSTALLOPTIONS_WRITE $IPADDRESS2 "xBConfig.ini" "${UIIPADDRESS2}" "State"
!insertmacro MUI_INSTALLOPTIONS_WRITE $PORT2 "xBConfig.ini" "${UIPORT2}" "State"
Abort

${Case} "${UIDISABLETOR}"
!insertmacro MUI_INSTALLOPTIONS_READ $tmpstate2 "xBConfig.ini" "${UIDISABLETOR}" "State"
${If} $tmpstate2 == "1"
StrCpy $tmpstate2 "0"
${Else}
StrCpy $tmpstate2 "1"
${EndIf}
!insertmacro CHANGEGROUPSTATE2 $tmpstate2
Abort
${EndSwitch}

!insertmacro MUI_INSTALLOPTIONS_READ $IPADDRESS1 "xBConfig.ini" "${UIIPADDRESS1}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $PORT1 "xBConfig.ini" "${UIPORT1}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $IPADDRESS2 "xBConfig.ini" "${UIIPADDRESS2}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $PORT2 "xBConfig.ini" "${UIPORT2}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $PROXYREQ "xBConfig.ini" "${UIPROXYREQ}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $DISABLEWARNING "xBConfig.ini" "${UIDISABLEWARNING}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $DISABLESPLASH "xBConfig.ini" "${UIDISABLESPLASH}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $DISABLETOR "xBConfig.ini" "${UIDISABLETOR}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $WAITFORCIRCUIT "xBConfig.ini" "${UIWAITFORCIRCUIT}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $TORTIMEOUT "xBConfig.ini" "${UITORTIMEOUT}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $CONTROLPORT "xBConfig.ini" "${UICONTROLPORT}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $SOCKSPORT "xBConfig.ini" "${UISOCKSPORT}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $REQAUTH1 "xBConfig.ini" "${UIREQAUTH1}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $REQAUTH2 "xBConfig.ini" "${UIREQAUTH2}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $DEBUGON "xBConfig.ini" "${UIDEBUGON}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $TORCOMMANDS "xBConfig.ini" "${UITORCOMMANDS}" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $DELDIRDATA "xBConfig.ini" "${UIDELDIRDATA}" "State"


; convert 1 = true, 0 = false
${If} $DISABLEWARNING = 1
StrCpy $DISABLEWARNING "true"
${ElseIf} $DISABLEWARNING = 0
StrCpy $DISABLEWARNING "false"
${EndIf}

${If} $DISABLESPLASH = 1
StrCpy $DISABLESPLASH "true"
${ElseIf} $DISABLESPLASH = 0
StrCpy $DISABLESPLASH "false"
${EndIf}

${If} $DISABLETOR = 1
StrCpy $DISABLETOR "true"
${ElseIf} $DISABLETOR = 0
StrCpy $DISABLETOR "false"
${EndIf}

${If} $WAITFORCIRCUIT = 1
StrCpy $WAITFORCIRCUIT "true"
${ElseIf} $WAITFORCIRCUIT = 0
StrCpy $WAITFORCIRCUIT "false"
${EndIf}

${If} $DELDIRDATA = 1
StrCpy $DELDIRDATA "true"
${ElseIf} $DELDIRDATA = 0
StrCpy $DELDIRDATA "false"
${EndIf}


; TODO: save values to ini file/registry...
${If} $DEBUGON = 1 ;To create the log file, we need debugon to be written as 2, a 1 will just cause popups.
StrCpy $DEBUGON 2
${EndIf}

FileOpen $6 "$EXEDIR\..\XeroBank.ini" w
FileWrite $6 ";Don't use Notepad to read or wite to this file. Use some other text editor like Wordpad. $\r"
FileWrite $6 ";If you need to manually upgrade to XeroBank service, ServiceLevel 1 is XeroBank Basic, 2 is XeroBank Plus, and 3 is XeroBank Pro$\r"
FileWrite $6 ";If upgrading to XeroBank Basic, put the XeroBank.key file in the \Data\XeroBank\ directory$\r"
FileWrite $6 ";If you are manually adding your proxy credentials, then set the ProxyAuths like so: username:password$\r$\r"

;*************************************** Write the XeroBank Section *******************************
FileWrite $6 "[XeroBank]$\r"
FileWrite $6 "TorDirectory=App\tor$\r"
FileWrite $6 "OutPath=App$\r"
FileWrite $6 "TimerMax=$TORTIMEOUT$\r"
FileWrite $6 "ServiceLevel=$\r"
FileWrite $6 "WaitForTorCircuit=$WAITFORCIRCUIT$\r"
FileWrite $6 "SubmissiveMode=$DISABLETOR$\r"
FileWrite $6 "DeleteDirData=$DELDIRDATA$\r"
FileWrite $6 "SOCKSPort=$SOCKSPort$\r"
FileWrite $6 "ControlPort=$ControlPort$\r"
FileWrite $6 "DebugOn=$DebugOn$\r"
FileWrite $6 "TorCommands=$TorCommands$\r"
FileWrite $6 "GnuPGPATHDIRECTORYApp\gpg$\r"
FileWrite $6 "GnuPGHOMEDIRECTORY=Data\gpg$\r"

;****************************** Write the proxy data to the XeroBank section ***************************

${If} $PROXYREQ = 1 ;If there is a proxy, write out the proxy data
FileWrite $6 "ProxyRequired=Yes$\r"
${If} $IPADDRESS1 != "IP Address"
FileWrite $6 "HttpProxyAddress=$IPADDRESS1$\r"
FileWrite $6 "HttpProxyPort=$PORT1$\r"
${If} $REQAUTH1 = 1
FileWrite $6 "HttpProxyAuth=Ask$\r"
${ElseIf} $REQAUTH1 = 0
FileWrite $6 "HttpProxyAuth=No$\r"
${EndIf}
${ElseIf} $IPADDRESS1 == "IP Address"
FileWrite $6 "HttpProxyAddress=$\r"
FileWrite $6 "HttpProxyPort=$\r"
FileWrite $6 "HttpProxyAuth=$\r"
${EndIf}
${If} $IPADDRESS2 != "IP Address"
FileWrite $6 "HttpsProxyAddress=$IPADDRESS2$\r"
FileWrite $6 "HttpsProxyPort=$PORT2$\r"
${If} $REQAUTH2 = 1
FileWrite $6 "HttpsProxyAuth=Ask$\r"
${ElseIf} $REQAUTH2 = 0
FileWrite $6 "HttpsProxyAuth=No$\r"
${EndIf}
${ElseIf} $IPADDRESS2 == "IP Address"
FileWrite $6 "HttpsProxyAddress=$\r"
FileWrite $6 "HttpsProxyPort=$\r"
FileWrite $6 "HttpsProxyAuth=$\r"
${EndIf}

${ElseIf} $PROXYREQ = 0 ;If there is no proxy, zero out the lines.
FileWrite $6 "ProxyRequired=No$\r"
FileWrite $6 "HttpProxyAddress=$\r"
FileWrite $6 "HttpProxyPort=$\r"
FileWrite $6 "HttpProxyAuth=$\r"
FileWrite $6 "HttpsProxyAddress=$\r"
FileWrite $6 "HttpsProxyPort=$\r"
FileWrite $6 "HttpsProxyAuth=$\r"
${EndIf}

;******************************************** Now Write the Browser Prefs *********************
FileWrite $6 "$\r"
FileWrite $6 "[${BROWSERNAME}]$\r"
FileWrite $6 "ProgramDirectory=App\Browser\firefox$\r"
FileWrite $6 "ProgramExecutable=firefox.exe$\r"
FileWrite $6 "ProfileDirectory=Data\Browser\profile$\r"
FileWrite $6 "PluginsDirectory=Data\Browser\plugins$\r"
FileWrite $6 "TempDirectory=App\Browser\temp$\r"
FileWrite $6 "UserProfileDirectory=Data\Browser\userprofile$\r"
FileWrite $6 "DisableSplashScreen=$DISABLESPLASH$\r"
FileWrite $6 "DisableWarning=$DISABLEWARNING$\r"
FileWrite $6 "SkipChromeFix=false$\r"
FileWrite $6 "SkipCompregFix=false$\r"
FileWrite $6 "LocalHomePage=$\r"

;******************************************** Now Write the Mail Prefs *********************
FileWrite $6 "$\r"
FileWrite $6 "[${MAILCLIENTNAME}]$\r"
FileWrite $6 "ProgramDirectory=App\Mail\thunderbird$\r"
FileWrite $6 "ProgramExecutable=thunderbird.exe$\r"
FileWrite $6 "ProfileDirectory=Data\thunderbird\profile$\r"
FileWrite $6 "PluginsDirectory=Data\thunderbird\plugins$\r"
FileWrite $6 "TempDirectory=App\thunderbird\temp$\r"
FileWrite $6 "UserProfileDirectory=Data\thunderbird\userprofile$\r"
FileWrite $6 "DisableSplashScreen=$DISABLESPLASH$\r"
FileWrite $6 "DisableWarning=$DISABLEWARNING$\r"
FileWrite $6 "SkipChromeFix=false$\r"
FileWrite $6 "SkipCompregFix=false$\r"

;********************************************* And now close the file **************************
FileClose $6

; Firewall-Disabler::QueryFirewall
; Pop $R0
; StrCmp $R0 "1" "" +2
; Messagebox MB_OK "xBConfig has detected that the Windows Firewall is enabled.$\nIf you experience trouble with XeroBank software, try disabling it."
FunctionEnd

Function GetProxySettings
ReadRegDWORD $R0 HKCU "Software\Microsoft\Windows\CurrentVersion\Internet Settings" ProxyEnable ;Check registry to see if proxy is enabled
${If} $R0 = 1
ReadRegStr $R0 HKCU "Software\Microsoft\Windows\CurrentVersion\Internet Settings" ProxyServer ;Read the proxy string from the reg.
${WordFind2X} "$R0" "http=" ";" "E+1" $3 ;Get http proxy data. if error, set to 1
${If} $3 != 1 ;If there is no error, do the following
StrCpy $HTTPPROXY $3
${WordFind} "$HTTPPROXY" ":" "+1" $IPADDRESS1
${WordFind} "$HTTPPROXY" ":" "-1" $PORT1
${EndIf}
${WordFind2X} "$R0" "https=" ";" "E+1" $3 ;Get https proxy data. if error, set to 1
${If} $3 != 1 ;If there is no error, do the follwing:
StrCpy $HTTPSPROXY $3
${WordFind} "$HTTPSPROXY" ":" "+1" $IPADDRESS2 ;Split it up
${WordFind} "$HTTPSPROXY" ":" "-1" $PORT2
${EndIf}
${ElseIf} $R0 = 0
MessageBox MB_OK "No Proxy Data Found. Assuming Direct Connection to Internet"
${EndIf}
FunctionEnd

Please attach large scripts.

One note is do not mix and match MUI pages with standard pages, i.e. do not use Page Directory, use !insertmacro MUI_PAGE_DIRECTORY.

Stu


Okay good news. I've got it doing most of what I want it to do.

X 0. Display the License
X 1. Install the program
X a. Ask the directory
X b. Create some temp files and extract
2. Get Proxy Information
X a. Firewall test
X b. Use It
X 3. Take serial number and download program using serial data.
a. Change box colors.
X 4. Create Icons.

So we still have some issues.

How can I change the serial box colors? (passdialog plugin)

In the example below, the code changes the color. How do I do that with my code? How do I figure out the values?


Name "PassDialog InputBox"
OutFile "PassDialog-InputBox.exe"

## Include headers
!include MUI.nsh

## Pages
!insertmacro MUI_PAGE_WELCOME
Page Custom InputBoxPageShow InputBoxPageLeave
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES

## Password is
!define Password "blah"
!define Username "Jeff"

## Control ID's
!define IDC_INPUTBOX 1216

## Languages
!insertmacro MUI_LANGUAGE English

## Displays the input box dialog
Function InputBoxPageShow

!insertmacro MUI_HEADER_TEXT "Enter Details" "Enter your details."

PassDialog::InitDialog /NOUNLOAD InputBox /BOX "ja" "hello" 0
Pop $R0 # Page HWND

GetDlgItem $R1 $R0 ${IDC_INPUTBOX}
SetCtlColors $R1 0xFF0000 0xFFFF00

PassDialog::Show

FunctionEnd

## Validate inpu
Function InputBoxPageLeave

## Pop details from stack
Pop $R0

## Display the details
MessageBox MB_OK|MB_ICONINFORMATION "You entered: $R0 !"

FunctionEnd

## Just a dummy section
Section 'A section'
SectionEnd


And here is my code for the serial box:


Function InitPage

!insertmacro MUI_HEADER_TEXT "Upgrade xB Browser" "Enable XeroBank Plus Service"

PassDialog::Dialog Serial \
/HEADINGTEXT 'Enter your XeroBank Transaction ID, displayed when you login at xerobank.com' \
/CENTER \
/BOXDASH 12 50 4 '' \
/BOXDASH 72 50 4 '' \
/BOXDASH 132 50 4 '' \
/BOX 192 50 4 '' \


Pop $R0 # success, back, cancel or error

FunctionEnd

Notice the InitDialog and Show calls and what is in between.

Stu


The ${IDC_INPUTBOX} however, is from up above. And that seems to make all the difference in the world. What would be the corresponding !define Control ID(s) and # for the serial boxes?


I believe it tells you in the readme file.

Stu