Archive: Different user get different install options


Different user get different install options
  Hi,
Sorry i'm completly new to nsis and i want to make an installer that gives different useres different install options so that they can maybe enter a user name and a password and then get installoptions specific to their user name.I've already tried it with user pass but their i couldnt figure it out how i can seperate installoptions to a signle account.
greets
citytstars


1) In the user/pass custom page's LEAVE function, set a variable $installtype depending on what user/pass is entered.
2) In each following page's PRE function, do this:
${If} $installtype != "some value"
abort
${EndIf}

That should be all.


i dont know where to define the user name now i'm using the userpass plugin


Name    "PassDialog UserPass"

>OutFile "PassDialog-UserPass.exe"
>RequestExecutionLevel user
>## Include headers
>!include MUI.nsh
>!include LogicLib.nsh
>## Pages
>!insertmacro MUI_PAGE_WELCOME
Page Custom UserPassPageShow UserPassPageLeave
>!define MUI_PAGE_CUSTOMFUNCTION_SHOW ComponentsPageShow
>## !insertmacro MUI_PAGE_COMPONENTS
>!insertmacro MUI_PAGE_INSTFILES

>## Password is
>!define Username1 "Jeff"
>!define Password1 "blah"
>!define Username2 "stealth"
>!define Password2 "zero"

>## Control ID's
>!define IDC_USERNAME 1215
>!define IDC_PASSWORD 1214

>## Languages
>!insertmacro MUI_LANGUAGE English

>## Displays the username and password dialog
>Function UserPassPageShow

>!insertmacro MUI_HEADER_TEXT "Enter Username && Password" "Enter your username and password to continue."

>PassDialog::InitDialog /NOUNLOAD UserPass
Pop $R0 # Page HWND

GetDlgItem $R1 $R0 ${IDC_USERNAME}
SetCtlColors $R1 0xFF0000 0xFFFFFF
GetDlgItem $R1 $R0${IDC_PASSWORD}
SetCtlColors $R1 0x0000FF 0xFFFFFF

PassDialog
::Show

FunctionEnd

## Validate username and password
>Function UserPassPageLeave


>## Pop password & username from stack
>Pop $R0
Pop $R1
Pop $R2
Pop $R3

>## A bit of validation
>StrCmp $R0 '${Username1}' 0 +2
StrCmp $R1'${Password1}' Good Bad
StrCmp $R2'${Username2}' 0 +2
StrCmp $R3'${Password2}' Good Bad

Bad:
>MessageBox MB_OK|MB_ICONEXCLAMATION "The entered username or password is incorrect!"
>Abort

Good:

>FunctionEnd

>/*Function ComponentsPageShow

## Disable the Back button
GetDlgItem $R0 $HWNDPARENT 3
EnableWindow $R0 0

FunctionEnd
*/
>Section 'A section'
>SectionEnd

abort
>

now i mange to get a choice between 2 user but its not hidden so that user 2 can easily install what only user 1 should be able to install. and the other way around. PLease help me one more time :D


Name    "PassDialog UserPass"

>OutFile "PassDialog-UserPass.exe"
>RequestExecutionLevel user
>## Include headers
>!include MUI.nsh
>!include LogicLib.nsh
>## Pages
>!insertmacro MUI_PAGE_WELCOME
Page Custom UserPassPageShow UserPassPageLeave
>!define MUI_PAGE_CUSTOMFUNCTION_SHOW ComponentsPageShow
>!insertmacro MUI_PAGE_COMPONENTS

>!insertmacro MUI_PAGE_INSTFILES
>var installtype

InstType "User1"
>InstType "User2"

>## Password is
>!define Username1 "Jeff"
>!define Password1 "blah"
>!define Username2 "stealth"
>!define Password2 "zero"

>## Control ID's
>!define IDC_USERNAME 1215
>!define IDC_PASSWORD 1214

>## Languages
>!insertmacro MUI_LANGUAGE English


>## Displays the username and password dialog
>Function UserPassPageShow

>!insertmacro MUI_HEADER_TEXT "Enter Username && Password" "Enter your username and password to continue."

>PassDialog::InitDialog /NOUNLOAD UserPass
Pop $R0 # Page HWND

GetDlgItem $R1 $R0 ${IDC_USERNAME}
SetCtlColors $R1 0xFF0000 0xFFFFFF
GetDlgItem $R1 $R0${IDC_PASSWORD}
SetCtlColors $R1 0x0000FF 0xFFFFFF

PassDialog
::Show

FunctionEnd

## Validate username and password
>Function UserPassPageLeave

>## Pop password & username from stack
>Pop $R0
Pop $R1

>## A bit of validation
>StrCmp $R0 '${Username1}' 0 +4
StrCmp $R1'${Password1}' 0 Bad
SetCurInstType 0
GOTO Good
StrCmp $R0'${Username2}' 0 +4
StrCmp $R1'${Password2}' 0 Bad
SetCurInstType 1
GOTO Good

Bad:
>MessageBox MB_OK|MB_ICONEXCLAMATION "The entered username or password is incorrect!"
>Abort

Good:

>FunctionEnd



>Function ComponentsPageShow

>${If} $installtype == "0"

>${EndIf}


## Disable the Back button
GetDlgItem $R0 $HWNDPARENT 3
EnableWindow $R0 0

FunctionEnd

Section 'A section'
>SectionIn 1
SectionEnd

Section 'B section'
>SectionIn 2
SectionEnd
>

any ideas?