I am using and InstallShield installer setup.exe file to silently install my app. Now I want to invoke setup.exe with some command line arguments. And that arguments should be available in a EXE custom action that I have created to be executed at success. How can I pass the data all over from command line while invoking the setup file and use it inside my exe. The exe is a console app written in C#.
Asked
Active
Viewed 2,291 times
1 Answers
0
I understand this is an MSI-based project, and I assume the .exe custom action is deferred execution.
What you should do is this:
- In your installer, define some custom MSI properties which you need for the .exe (e.g.
ServerName
,ServerPort
) - Create a custom action of type 'Set a property'. The Property Name should be the name of your custom action which runs the exe (e.g.
RunMyExe
). The Property Value should be a concatenated list of your custom properties e.g.[ServerName];[ServerPort]
. Make this custom action run after InstallInitialize. - In your .exe custom action (RunMyExe), pass
[CustomActionData]
as the Command Line to your exe program - Have your exe program get the command line, and split it in order to get the data it needs
- Invoke the setup.exe while setting those custom properties you defined in step 1, e.g.
setup.exe /v"ServerName=test-srv ServerPort=67000"
What happens is that, on a deferred custom action you can't use exernal properties (such as those supplied from the command line), you can only access internal ones such as CustomActionData. The trick here is that, if a property with the action's name exists (RunMyExe in the example above), the internal CustomActionData property get its value from it.

yossiz74
- 889
- 1
- 9
- 16
-
Note that even a deferred exe custom action can reference any property in its command line. – Michael Urman Mar 30 '16 at 11:57
-
As far as i remember, only public properties can be passed to MSI by command line. So, i'd say, your suggestion will not work. – Vadim Mar 31 '16 at 08:27
-
"CustomActionData" isn't a property you can pass at the command line. It only exists in the context of a deferred custom action and maps to the name of the custom action itself. – Christopher Painter Mar 31 '16 at 13:10
-
You are correct. I was mislead by some shortcut we have here. I am updating my original answer with the full solution. – yossiz74 Mar 31 '16 at 13:32