Old 6th May 2013, 12:32   #1
citystars
Junior Member
 
Join Date: May 2013
Posts: 5
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
citystars is offline   Reply With Quote
Old 6th May 2013, 15:30   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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.
MSG is offline   Reply With Quote
Old 7th May 2013, 10:44   #3
citystars
Junior Member
 
Join Date: May 2013
Posts: 5
i dont know where to define the user name now i'm using the userpass plugin
PHP Code:
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}' +2
StrCmp $R1 
'${Password1}' Good Bad
StrCmp $R2 
'${Username2}' +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 
citystars is offline   Reply With Quote
Old 7th May 2013, 16:43   #4
citystars
Junior Member
 
Join Date: May 2013
Posts: 5
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
PHP Code:
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}' +4
StrCmp $R1 
'${Password1}' 0 Bad
SetCurInstType 0
GOTO Good
StrCmp $R0 
'${Username2}' +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 
citystars is offline   Reply With Quote
Old 13th May 2013, 08:28   #5
citystars
Junior Member
 
Join Date: May 2013
Posts: 5
any ideas?
citystars is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump