Archive: Silent install with parameters


Silent install with parameters
I would like to create an installer that runs silently but allows a network administrator to distribute to users with certain installer parameters pre-defined. I'm not referring to the install folder, but actually user parameters. For example, if my installer allows a user to pick Option A, B and/or C during the normal installation process, if I were to run this in silent mode, I would still want to define, perhaps in a command line, whether a user is installing with which option, or perhaps the word "All" for all three.

I would create the scripts to receive these parameters or arguments and automatically install the program with the proper options, so that the user doesn't have to decide for themselves.

In a network/corporate environment, there may be different types of users that need different options, but I'd want the silent installer to handle each one appropriately.

Can this be done? How would I pass in these options as part of a silent install process?

Thanks.


GetParameters and GetOptions.

Stu


Thanks for the prompt reply. So, if the compiled install package is "myInstall.exe", would I run that with the following:

myInstall "OptionA"

or

myInstall "OptionA, OptionC"

or

myInstall "All"

and the GetParameters() or GetOptions() will pass the particular string into my scripts?

That will be perfect if that is what you are meaning.


rtfm...
http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.11
http://forums.winamp.com/showthread.php?postid=2211469


I think I may not have clearly stated my question. I've read the manual and I think I understand how GetParameters and GetOptions work. What I am after is a desire to define my own commandline parameters. Not simply a /S or /D option, but something that is very specific to my application. It might be a list of room names, users, etc. that are default parameters that I want to assign to the installed app without the user having to go through the UI to select them. I know that I can create set of custom pages to request this information. But can I pass in the details through commandline parameters?


Yes you can, using what Stu AND jpderuiter already pointed you at. Or if you want to pass params to your application, instead of to your installer, you can do that to. Pay attention to the quote usage:

Exec '"$INSTDIR\YourApp.exe" Param1 Param2 ParamEtc'


Got it working
When I am part of a forum, I try to give back as much as I get from a forum. So, here is a bit more detail on how to get this working, if anyone else is trying to do the same thing. The information that you offered (and that is in the manual) is correct, but there are a few missing pieces that I couldn't find anywhere. I just happened to guess on a few things and got lucky.

To begin with, at the top of your script, you have to include the following or GetParameters and GetOptions won't even compile:

!include "FileFunc.nsh" ; this is critical

Next, the parameters themselves are not put into double quotes. Using the following code

Var roomList

Function .onInit
var /GLOBAL cmdLineParams
Push $R0
${GetParameters} $cmdLineParams
Pop $R0
FunctionEnd

; Then add the following code goes in the main section
; where the StartMenu shortcut and other commands
; get executed.

${GetOptions} $cmdLineParams "/Params=" $R0
IfErrors +2 0
StrCpy $paramList "$R0"

Then the installer is executed with the following command line.

myInstall.exe /Params=P1,P2,P3

The end result is that $paramList will contain "P1,P2,P3".

Hope this helps others. If anyone wants to comment on other ways to clean up the above code, that will help all of us.


If you look at where GetParameters and GetOptions are located in the helpfile you will see that they are in the "Appendix E: Useful Headers" section, the first thing the file function header section tells you in "E.1.1 Introduction" is to !include "FileFunc.nsh"

Your ${GetParameters} usage is weird, there is no need to push and pop, just use ${GetParameters} $cmdLineParams (The helpfile documents the syntax as "${GetParameters} $var", the example just uses $R0)


I realize that now, but as a newbie, it isn't that obvious. If someone just points you to GetParameters and GetOptions and doesn't explain how to use any of those functions in general, you would miss that important item. I saw another post that explained a far more complete description for these functions that also didn't include that line.

And yes, I suspected that I could take out the push and pop but that was how the usage was explained in another thread and since it is working, I haven't gone back to see what I could remove and what was absolutely required.

Thanks for the clarification.