sskanna82
Posts: 7
Joined: Wed Jun 24, 2009 7:59 am

Passing arguments to a exe

Hi,

I want to run a exe after install custom action and i want to pass arguments for that exe which features are selected and installed? Since i use a exe to run the SQl scripts for Database configuration. So, based on the installed features i want to run the particular SQL Scripts. Can you any one suggest me about this?

Thanks in Advance,
Kannan .S
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Passing arguments to a exe

Hello,

Let us assume you have three features: Feature1, Feature2 and Feature3, and your executable's name is "my.exe"
In order to implement this behaviour, you need to follow these steps:
- in the Install Parameters page, add three new properties: SELECTED1 SELECTED2 and SELECTED3, each with the value 0 (note that the properties must be written in uppercase)
- in the Dialogs page add the SetupTypeDlg in order to enable feature selection
- on the VerifyReadyDlg, on the Install button, Published Events tab, add a three new SetProperty events
- set the properties to SELECTED1 SELECTED2 and SELECTED3 respectively, the values to 1. For the conditions, press the "..." button, and select Feature State
- select the feature that corresponds to the property you are setting
- from the published events list, select each event you created and push it upwards as much as possible using the Up button
- in the Custom Actions page, under Install, create a new "EXE with working directory" custom action
- in this custom action's "Full Path" field input this:

Code: Select all

"[APPDIR]my.exe" [SELECTED1] [SELECTED2] [SELECTED3]
- note that my.exe must be in the installation folder when the custom action is run. You can add it as a temporary file in "Files and Folders" page if you do not need it after install, otherwise make sure the custom action runs after everything is installed.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
sskanna82
Posts: 7
Joined: Wed Jun 24, 2009 7:59 am

Re: Passing arguments to a exe

GabrielBarbu wrote:Hello,

Let us assume you have three features: Feature1, Feature2 and Feature3, and your executable's name is "my.exe"
In order to implement this behaviour, you need to follow these steps:
- in the Install Parameters page, add three new properties: SELECTED1 SELECTED2 and SELECTED3, each with the value 0 (note that the properties must be written in uppercase)
- in the Dialogs page add the SetupTypeDlg in order to enable feature selection
- on the VerifyReadyDlg, on the Install button, Published Events tab, add a three new SetProperty events
- set the properties to SELECTED1 SELECTED2 and SELECTED3 respectively, the values to 1. For the conditions, press the "..." button, and select Feature State
- select the feature that corresponds to the property you are setting
- from the published events list, select each event you created and push it upwards as much as possible using the Up button
- in the Custom Actions page, under Install, create a new "EXE with working directory" custom action
- in this custom action's "Full Path" field input this:

Code: Select all

"[APPDIR]my.exe" [SELECTED1] [SELECTED2] [SELECTED3]
- note that my.exe must be in the installation folder when the custom action is run. You can add it as a temporary file in "Files and Folders" page if you do not need it after install, otherwise make sure the custom action runs after everything is installed.

Regards,
Gabriel
Hi Gabriel,

Thanks for your reply.Now it is clear to me how to pass the arguments for a exe. One more clarification for me how can i retrieve those properties values in that exe?

Thannks in Advance,
Kannan .S
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Passing arguments to a exe

Note that your executable recieves the values of those properties and not the property names themselves. So your executable will be ran with arguments somewhat like this:

Code: Select all

my.exe 0 1 1
If you are writing your executable in C, then your main function would look like this:

Code: Select all

int main(int argc, char* argv[])
Where argc is the number of arguments passed to your executable, and argv is an array containing your arguments.
If you are not using the C/C++ language, then please consult the documentation of your language for information on how to access the arguments passed to your executable.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”