Skip to content
⌘ NSIS Forum Archive

Silent Installer using NSIS

7 posts

newbie1983_blr#

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
Afrow UK#
There are no pages in silent mode. Therefore if you have any code in page callbacks, they will never execute in silent mode.

Stu
newbie1983_blr#
Can you suggest any other way where i can perform my operation and compatible to silent too.
newbie1983_blr#
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
JasonFriday13#
Perhaps something like this (untested):
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} $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
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