Old 21st January 2015, 05:39   #1
newbie1983_blr
Junior Member
 
Join Date: Jan 2015
Posts: 4
Smile Silent Installer using NSIS

Hello Team,

I am overwhelmed to be part of this forum.
I am a newbie started using NSIS since Nov 2014 extensively to create a client installer for our product.

Currently i am working on converting the same installer to silent mode.
I have created a installer which accepts Login and Password as parameter.
1. I check using inetc:ost method and pass username and password to for existense of those accounts in my db
2. I authenticate using inetc::get method
3. I pull a certificate based on the user details using inetc::get method
4. Install the content

I use Setsilent method on Function .OnInit to test for now.

Function .onInit

MessageBox MB_YESNO|MB_ICONQUESTION "Would you like the installer to be silent from now on?" \
/SD IDYES IDNO no IDYES yes
yes:
SetSilent silent
Goto Installer
no:
SetSilent normal
Installer:

Following observations i made upon trying out silent installation.

as soon i select silent installation all inetc methods are not executing but content is dropped to expected folder.
No authentication , no certficate is getting downloaded.

Can you help me with this problem.

Thank you in advance.
Awaiting for your reply
newbie1983_blr is offline   Reply With Quote
Old 21st January 2015, 09:13   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
There are no pages in silent mode. Therefore if you have any code in page callbacks, they will never execute in silent mode.

Stu
Afrow UK is offline   Reply With Quote
Old 22nd January 2015, 08:36   #3
newbie1983_blr
Junior Member
 
Join Date: Jan 2015
Posts: 4
Can you suggest any other way where i can perform my operation and compatible to silent too.
newbie1983_blr is offline   Reply With Quote
Old 22nd January 2015, 13:05   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
You can use IfSilent or ${If} ${Silent} to perform required operations in your sections...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 23rd January 2015, 05:36   #5
newbie1983_blr
Junior Member
 
Join Date: Jan 2015
Posts: 4
Hello team,

Thank you for your time and hint.
This is a code snippet which i want to make silent
Can you give me an example using the same code snippet.
This would be of great help to us.

Function Authenticate
#Call to REST API for user authentication
nsJSON::Set /file "c:\temp\<some file>"
ShowWindow $WAITMSG ${SW_SHOW}
${NSD_SetText} $WAITMSG "User authentication in progress...."
AnimGif:lay /NOUNLOAD /HALIGN=83 /VALIGN=73 $PLUGINSDIR\a.gif
inetc:ost "grant_type=password&username=$UserNameText&password=$UserPwdText" /SILENT "<URL>" "c:\temp\<some file>" /END
NsisCrypt::Base64Encode $UserNameText
Pop $1
#MessageBox MB_OK $1
nsJSON::Set /file "c:\temp\<some file>" /END
nsJSON::Get /exists "access_token" /END
Pop $0
${If} $0 == "yes"
nsJSON::Get "access_token" /END
Pop $TOKEN
#MessageBox MB_OK $TOKEN
StrCpy $isValidUser "true"
#Call to REST API for getting the institution details
${NSD_SetText} $WAITMSG "Getting Institution details...."
inetc::get /SILENT "<URL>" "c:\temp\<some file>" /END

nsJSON::Set /file "c:\temp\<some file>" /END
nsJSON::Get /count /END
Pop $INSTITUTIONCOUNT
${Else}
StrCpy $isValidUser "false"
${EndIf}
#delete "c:\temp\<some file>"
ShowWindow $WAITMSG ${SW_HIDE}
AnimGif::stop
FunctionEnd
newbie1983_blr is offline   Reply With Quote
Old 27th January 2015, 05:24   #6
newbie1983_blr
Junior Member
 
Join Date: Jan 2015
Posts: 4
Hello team,

I request experts , Moderator, Senior Member to help me with this.
newbie1983_blr is offline   Reply With Quote
Old 27th January 2015, 07:17   #7
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 906
Perhaps something like this (untested):
PHP Code:
Function Authenticate
#Call to REST API for user authentication
nsJSON::Set /file "c:\temp\<some file>"
IfSilent skipGuiStart
  ShowWindow $WAITMSG 
${SW_SHOW}
  ${
NSD_SetText$WAITMSG "User authentication in progress...."
  
AnimGif:lay /NOUNLOAD /HALIGN=83 /VALIGN=73 $PLUGINSDIR\a.gif
skipGuiStart
:
inetc:ost "grant_type=password&username=$UserNameText&password=$UserPwdText/SILENT "<URL>" "c:\temp\<some file>" /END
NsisCrypt
::Base64Encode $UserNameText
Pop 
$1
#MessageBox MB_OK $1
nsJSON::Set /file "c:\temp\<some file>" /END
nsJSON
::Get /exists "access_token" /END
Pop 
$0
${If} $== "yes"
nsJSON::Get "access_token" /END
Pop $TOKEN
#MessageBox MB_OK $TOKEN
StrCpy $isValidUser "true"
#Call to REST API for getting the institution details
IfSilent skipGuiSetText
  
${NSD_SetText$WAITMSG "Getting Institution details...."
skipGuiSetText:
inetc::get /SILENT "<URL>" "c:\temp\<some file>" /END

nsJSON
::Set /file "c:\temp\<some file>" /END
nsJSON
::Get /count /END
Pop $INSTITUTIONCOUNT
${Else}
StrCpy $isValidUser "false"
${EndIf}
#delete "c:\temp\<some file>"
IfSilent skipGuiEnd
  ShowWindow $WAITMSG 
${SW_HIDE}
  
AnimGif::stop
skipGuiEnd
:
FunctionEnd

First section
Section 
-SilentAuth
  IfSilent 0 
+2
    Call Authenticate
SectionEnd

Other sections follow 

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
silent installer

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