Archive: filling passwords needed in a silent installation


filling passwords needed in a silent installation
Hi all, I have read all of the other posts and could not find any information regarding this subject.

Will I be able to pass information to a silent installation... Lets say I am trying to do a "silent" install of a database that requires information such as username and password, etc. How can automaticly fill in this information?

Any help would be greatly appreciated. I am really interested in getting this figured out, so any links to documentation or ideas on how to accomplish this, please. Thanks


Include a default password and username. If the installer is silent then install it using that


hi, thanks for such a fast response. I am not to sure what you mean by this , where do I provide this default password , is it some variable made in the script and then passed as a parameter? If you could explain a little I would seriosly appreciate. Thanks!


!define password "1234"
!define username "abc"


That will define the default username & password


IfSilent silent not

not:
;all normal stuff
goto done

silent:
;all silent stuff

done:

Take a look at the GetOptions macro defined in FileFunc.nsh. It allows command line options like /RESPONSE=responsefile.ini. If you format it as an .ini file, you can use the ReadINIStr commands to pull information out of it, such as usernames and passwords.

In our case we simply supply a sample response.ini file, so that our user can create their own to do silent installs like this:

OurSetup.exe /S /RESPONSE=responses.ini

...where responses.ini might contain:

; Global installation options
[Options]
InstallDir=C:\Program Files\MyApp
Password=password

Here's some sample script for getting the values:

!include FileFunc.nsh

...

!insertmacro GetOptions

...

StrCpy $1 ""
${GetOptions} $0 "/RESPONSE=" $1

IfErrors 0 RespExists
DetailsLogSet on
DetailPrint "*** No response file was specified for silent installation, setup will abort."
Abort

RespExists:
IfFileExists $1 RespFile
DetailsLogSet on
DetailPrint "*** Response file specified was not found for silent installation, setup will abort."
Abort

RespFile:
StrCpy $RespFile $1

ReadINIStr $0 $RespFile "Options" "InstallDir"
StrCmp $0 "" NoDir
StrCpy $INSTDIR $0

NoDir:
DetailsLogSet on
DetailPrint "Using response file $RespFile"


(You'll need to remove or replace the DetailsLogSet unless you use the build I posted about earlier, or replace it with LogSet and use LogText instead of DetailPrint.)

I am very new to this and have done a fare bit of reading just to get where I am.
I have a similar type of question as the OP.
I want to prompt for a password and then use the password later on. In my code below $Password has a value but not what was entered. What am I missing?

Additionally, the second last line (ExecDos::exec "%WINDIR%\system32\odbcad32.exe") simply does not execute.

TIA.

!include nsDialogs.nsh
!include LogicLib.nsh
Var Label
Var Dialog
Var Username
Var Password

Function pw
System::Call "advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2"
Pop $0
Strcpy $Username $0

nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog

${NSD_CreateLabel} 0 0 100% 36u "Enter login password for user: $Username. This will be used to schedule eTruancy Data Collector V3 to match your production schedule"
Pop $Label

${NSD_CreatePassword} 0 40u 100% 12u ""
Pop $Password


nsDialogs::Show

;The following line simply does not pop up the ODBC dialog box. Why?
ExecDos::exec "%WINDIR%\system32\odbcad32.exe"
FunctionEnd


Anyone?


In case any other newbie needs help...it may not be elegant but it works.

!include nsDialogs.nsh
!include LogicLib.nsh
Var Label
Var Dialog
Var Username
Var Pw
Var Password

Function pw
System::Call "advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2"
Pop $0
Strcpy $Username $0

nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog

${NSD_CreateLabel} 0 0 100% 36u "Enter login password for user: $Username. This will be used to schedule Data Collector V3 to match your production schedule"
Pop $Label

${NSD_CreatePassword} 0 40u 100% 12u ""
Pop $PW

GetFunctionAddress $0 EnterPassword
nsDialogs::OnChange /NOUNLOAD $PW $0
Call EnterPassword

nsDialogs::Show
strCpy $Password $R0

;Still can't get the following line to run
ExecDos::exec "%WINDIR%\system32\odbcad32.exe"
FunctionEnd

Function EnterPassword
Pop $0 # HWND
${NSD_GetText} $PW $R0
FunctionEnd


hmmm...
In your onChange callback, there should be no need to use the CALL command. Try this instead:


${NSD_CreatePassword} 0 40u 100% 12u ""
Pop $PW

${NSD_OnChange} $PW EnterPassword


(An alternative to this would be to just add the EnterPassword code as a page leave function instead of an onChange function. The advantage is that the function would only be called once after the entire password is entered instead of being called with every change.)

Also:
;The following line simply does not pop up the ODBC dialog box. Why?
ExecDos::exec "%WINDIR%\system32\odbcad32.exe"
The page show function is basically done once you call nsDialog::Show. So it would probably work better if add this code to the page's leave function or in a section depending on what your needs are.