Archive: Request : Tutorial on InstallOptions 2 using HM NIS Edit


Request : Tutorial on InstallOptions 2 using HM NIS Edit
  As most if not all of you know that HM NIS Edit comes with an InstallOptions dialog designer, will if some on could make a tutorial on how to get this to work that would be cool.

I am going for something like this : http://www.gnyso-strike.com/host/dyg.../NSISIO2_1.jpg

http://www.gnyso-strike.com/host/dyg.../NSISIO2_2.jpg

and would output this :

amx_admin "" "" "abcdefghijklmnopqrstu" "ce"


How the hell did he do all of this, thats what i need to know, and i am hoping for a tutorial on the subject.
Its not installing anything, its just adding a line to the file, Could some one show me code on all of this.

Talk to the developer. Although, as you say is only the designer...
you'll have to use the hand-code to make it work, as you can see the IO DOCs.


You can download a tutorial in MS-Word format here from this forum thread


1st thanks for replying all of you.

2nd ranametal, that helpe soo much meny thanks.

3rd Lobo Lunar, i know the guy quite well, but he is WAY more advaned then me, so when we talk its like " ok do this Pop $R1 ".
And i am like " WTF? ".
So he helps to a certain extent but hes just to good for me now.


Ok, followed that guide and i am stuck!

this is my code unedited.

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Admin"
!define PRODUCT_VERSION ".0a"
!define PRODUCT_PUBLISHER "AmxModX, Dygear."
!define PRODUCT_WEB_SITE "http://www.amxmodx.org"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"

SetCompressor lzma

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-colorful.ico"

; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "..\License\gpl.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Start menu page
var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Admin"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\gpl.txt"
!insertmacro MUI_PAGE_FINISH

; Language files
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"

; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Admin.exe"
InstallDir "$PROGRAMFILES\AmxModX Tools"
ShowInstDetails show

Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "..\License\gpl.txt"
CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\gpl.lnk" "$INSTDIR\gpl.txt"
SectionEnd

Section -AdditionalIcons
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
SectionEnd

Section -Post
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "${PRODUCT_STARTMENU_REGVAL}" "$ICONS_GROUP"
SectionEnd


It says to do this ...

Now you should note the Field numbers of the data entry controls. We are interested in

Username (Text – Field 2)
Password (Password – Field 4)

[Field 2]
Type=Text
Left=150
Right=300
Top=20
Bottom=35

[Field 4]
Type=Password
Left=150
Right=300
Top=40
Bottom=56



This example is using the Modern User Interface.

In you .onInit callback function, specify the INI filename and its alias. This is because I keep my INI files, graphics, etc in a sub-directory.

!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\UserPass.ini" "UserPass"


In your NSI script where you set up the page order:

LangString USERPASS_TITLE ${LANG_ENGLISH} "Enter your Username and Password."
LangString USERPASS_SUBTITLE ${LANG_ENGLISH} " "
Page custom UsernamePasswordPage


The custom page function:

# CUSTOM PAGE.
# =========================================================================
# Get the Username and Password.
Function UsernamePasswordPage

!insertmacro MUI_HEADER_TEXT "$(USERPASS_TITLE)" "$(USERPASS_SUBTITLE)"

# Display the page.
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "UserPass"

# Get the user entered values.
!insertmacro MUI_INSTALLOPTIONS_READ $Username "UserPass" "Field 2" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $Password "UserPass" "Field 4" "State"

FunctionEnd



The VARs $Username and $Password will contain the user entered values.
Thats all well and good, but how might i get this to work ?

*Note* Dygear = UberNoobie at NSIS
as you can see i did not even make the NSIS file myself. :confused:

Try this:


/* Installer Defines */


>!define PRODUCT_NAME "Admin"
>!define PRODUCT_VERSION ".0a"
>!define PRODUCT_PUBLISHER "AmxModX, Dygear."
>!define PRODUCT_WEB_SITE "http://www.amxmodx.org"
>!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"

>/* Default Installer Configuration */

>Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
>OutFile "Admin.exe"
>InstallDir "$PROGRAMFILES\\AmxModX Tools"
>ShowInstDetails show

SetCompressor lzma

>/* Include Modern UI 1.70 */

>!include "MUI.nsh"

/* MUI Settings */
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\\Contrib\\Graphics\\Icons\\modern-install-colorful.ico"

/* Language Selection Dialog Settings */
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

/* Page Configurations */

Page custom UsernamePasswordPage
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "..\\License\\gpl.txt"
!insertmacro MUI_PAGE_DIRECTORY

var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Admin"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP

!insertmacro MUI_PAGE_INSTFILES

!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\\gpl.txt"
!insertmacro MUI_PAGE_FINISH

/* Language files */

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"

/* Reserve files */

!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
ReserveFile "..\\Assets\\UserPass.ini"

/* Language strings */

/* Username and Password page */

LangString USERPASS_TITLE ${LANG_ENGLISH} "Enter your Username and Password."
LangString USERPASS_SUBTITLE ${LANG_ENGLISH} " "

>/* Special Functions */

/* .onInit */

Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "assets\\UserPass.ini" "UserPass.ini"
FunctionEnd

>/* Custom Page */

/* Username and Password page */
Function UsernamePasswordPage

!insertmacro MUI_HEADER_TEXT "$(USERPASS_TITLE)" "$(USERPASS_SUBTITLE)"

# Display the page.
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "UserPass.ini"

# Get the user entered values.
!insertmacro MUI_INSTALLOPTIONS_READ $Username "UserPass" "Field 2" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $Password "UserPass" "Field 4" "State"

FunctionEnd

>/* Sections */

/* MainSection */

Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "..\\License\\gpl.txt"
CreateDirectory "$SMPROGRAMS\\$ICONS_GROUP"
CreateShortCut "$SMPROGRAMS\\$ICONS_GROUP\\gpl.lnk" "$INSTDIR\\gpl.txt"
SectionEnd

/* Hidden Sections */

/* AdditionalIcons */

Section -AdditionalIcons
WriteIniStr "$INSTDIR\\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\\$ICONS_GROUP\\Website.lnk" "$INSTDIR\\${PRODUCT_NAME}.url"
SectionEnd

/* Post */

Section -Post
WriteRegStr${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "${PRODUCT_STARTMENU_REGVAL}" "$ICONS_GROUP"
SectionEnd
>

Did not work, look at this, see if you can compile it.

Do i need some extra dlls?
All i have is the stock NSIS 2.0.


Now I tested it and changed it to work. You only need to add the LangStrings for French and German and to add a funcionality of the User and Password page.

You have to put the script in a subfolder of a folder containing the Assets and License subfolders.


Thanks