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

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)

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?

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

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

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

How to execute program before the uninstallation starts?

Can InnoSetup execute a program before the uninstallation starts? My program creates some registry values. I have an executable that can remove those registry values and my question is, can InnoSetup run that executable before the uninstallation starts?
See the documentation on Setup Script Sections, particularly the UninstallRun one at the bottom of the tree:
[UninstallRun]
Filename: "{app}\INIT.EXE"; Parameters: "/x"
If you need to do something more complex, you can also do it in code using the Pascal scripting functionality in InnoSetup. See UninstallCodeExample1.iss' in theInnoSetup 5\Examples` folder.

how to display please wait dialog during EXEC() function

how to display please wait dialog while EXEC() runs another application silently.
You can use a ProgressOutputWizardPage, which works just fine for me, which isn't exactly complicated. You can refer to the CodeDlg.iss example.
Do you really need it to be a message box? As you might know, you can run an external *.exe during setup, and have a custom status message shown meanwhile. (The status message will be on the usual progress label during installation.)
I have a setup.exe that installs product A. This setup.exe contains a setup2.exe file, used to setup product B. setup.exe copies setup2.exe to the Program Files folder during the installation of product A. When all files have been copied, setup.exe then starts setup2.exe in the background. To accomplish this, i have done
[Run]
Filename: "{app}\setup2.exe"; StatusMSG: "Installing Product 2..."; Parameters: "/VERYSILENT /SUPPRESSMSGBOXES"
in setup.iss (that compiles to setup.exe). setup2.exe is also an Inno Setup installer, so the parameters "/VERYSILENT /SUPPRESSMSGBOXES" will make the installation of product 2 silent. During this setup, setup.exe will show the message "Installing Product 2...".
If you really need a message box to popup with the status message, you'll have to resort to Pascal scripting.

Resources