Old 29th January 2011, 16:42   #1
ssamuels_sv
Junior Member
 
Join Date: Jan 2011
Posts: 7
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.
ssamuels_sv is offline   Reply With Quote
Old 29th January 2011, 16:49   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
GetParameters and GetOptions.

Stu
Afrow UK is offline   Reply With Quote
Old 29th January 2011, 17:46   #3
ssamuels_sv
Junior Member
 
Join Date: Jan 2011
Posts: 7
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.
ssamuels_sv is offline   Reply With Quote
Old 29th January 2011, 21:25   #4
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
rtfm...
http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.11
http://forums.winamp.com/showthread.php?postid=2211469
jpderuiter is offline   Reply With Quote
Old 2nd February 2011, 01:31   #5
ssamuels_sv
Junior Member
 
Join Date: Jan 2011
Posts: 7
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?
ssamuels_sv is offline   Reply With Quote
Old 2nd February 2011, 04:50   #6
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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'
MSG is offline   Reply With Quote
Old 2nd February 2011, 19:40   #7
ssamuels_sv
Junior Member
 
Join Date: Jan 2011
Posts: 7
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.
ssamuels_sv is offline   Reply With Quote
Old 2nd February 2011, 19:57   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,281
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)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd February 2011, 20:20   #9
ssamuels_sv
Junior Member
 
Join Date: Jan 2011
Posts: 7
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.
ssamuels_sv is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
passing parameters, silent

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