How can I resolve installer command-line switch value in Inno Setup Pascal Script? - inno-setup

I am trying to fire a S2S pixel from the installer when an install is successful. The pixel require some details like the IP, location, time and sub-id.
I got all the details except the sub id, which is specified on the command line using /subID=xxxx switch, when executing the installer.

You can use the {param:ParamName} pseudo-constant.
See also Is it possible to accept custom command line parameters with Inno Setup.
In a Pascal Script you can resolve it using the ExpandConstant function:
ExpandConstant('{param:subID}')
If you need some custom parsing, you will have to parse the command-line explicitly by iterating the parameter list using the ParamStr and ParamCount function.
See some of the answers in the question linked above, and also:
Passing a string value to Inno Setup from command line app
Install files if command-line switch is passed to Inno Setup based installer

Related

How do we access command line switches passed to an Inno Setup uninstaller?

Can Inno Setup handle this?
How do we access command line parameters/switches passed to an Inno Setup uninstaller?
I'm trying to make a conditional uninstaller in Innosetup that can conditionally leave behind files. I'd like it to be silent, hence the command line switches.
You can use ParamStr and ParamCount functions.
In case your command-line switch have a value, using {param:ParamName} pseudo-constant can be more convenient.
For some examples, see some of more specific questions on Inno Setup custom command-line arguments:
Is it possible to accept custom command line parameters with Inno Setup
Passing conditional parameter in Inno Setup
How can I resolve installer command-line switch value in Inno Setup Pascal Script?

Add user defined command line parameters to /? window

With Inno Setup it is possible to add user defined command line parameters. When I use the /?, /HELP command the user defined parameters are not listed there. How can I add my commands with a description to the /?, /HELP window?
Inno Setup 6.0 supports HelpTextNote message, whose contents will be inserted into the /HELP box.
In older versions:
You cannot.
The help text is hard-coded and not customizable in any way. It's not even localized.
It is even displayed before any Pascal Script code (InitializeSetup) is executed, so there's even no room to install some fancy hook to modify the message box on runtime.
See the ShowHelp function in the SetupLdr.dpr.
All you can do is to implement a custom switch (e.g. /usage) and handle it in the InitializeSetup event function.
Or, of course, you can modify Inno Setup source code and re-compile it. It's open source.
A related question: Is it possible to accept custom command line parameters with Inno Setup

Default Values to Inno Setup install

I have a group at work asking if there is a way to pass in values, either via command line or an ini value, that will "fill in" values that are normally provided by the user during install. For example, if I have a drop down that the user can select they're installing the client, server, or both, they want a way to automate this so the user doesn't have to select anything.
Basically, they want to automate running the installer without actually showing the wizard panels and populating user values based on command line args or an ini file.
I know you can use ini files, but I don't think they're used for this reason. And I don't see any way that command args would be used.
Is there a way native to Inno Setup to do this?
Thanks!
One way to set all the standard settings at once is to use an INF file via the /LOADINF parameter.
It is also possible to extend this to custom page settings if you wish (with cooperation by the setup author).
There are many command line parameters already included in Inno which you can use: http://www.jrsoftware.org/ishelp/index.php?topic=setupcmdline
With them you can set task, directory, group, components, password etc etc.
If you need something special you can use your own command line parameters.
Use GetCmdTail() function to get cmd line parameters for setup or uninstaller.
As this is common question there are already some advanced parsers and methods like this one:
Is it possible to accept custom command line parameters with Inno Setup
I suggest you to use /SILENT parameter for not showing the setup forms together with e.g. /TASKS, /DIR and /COMPONENTS and some custom parameter.

Prevent a [Run] entry being processed with Inno Setup installer command line

I am running an installer that I built with Inno Setup, and I want to be able to control whether the applications runs or not after installation. I am using the [RUN] section to control this, but according the Inno docs, command line parameters can only control the [TASKS] section. Is there a way to enable/disable items in the [RUN] section from the command line?
Inno doesn't have an option to do this built in, but you can read the command line parameters and make use of the results in a Check: function on the [Run] entry.
In code, you can use the GetCmdTail, ParamCount and ParamStrfunctions, or the {param:} constant (but it isn't as good for a boolean option)

Is it possible to control which files to install from command line for INNO installer?

I would like to control a subset of files and only allow some of them to be installed if run with a command line switch for instance.
Is this possible?
For example
if (some condition)
install full set of files
else
Install other set of files
Alternatively I can just run another installer but then I have to pass the file/path location to that second installer. There is also the issue of bundling that second installer with the first one. I think that part is not that difficult though
Yes, it is even rather easy. There are several ways to do this, all of which depend on Pascal scripting.
Method 1
You can use the GetCmdTail, ParamCount, and ParamStr functions to obtain the entire or parts of the command-line.
Then you can use the Check parameter on separate files. Hence, each file will be installed if and only if the called function returns true.

Resources