Executing a batch file with parameter - Advanced Installer Community
nirs
Posts: 42
Joined: Wed Aug 13, 2014 2:46 pm

Executing a batch file with parameter

Hi,

After copying the relevant files of my program I need to execute one of those files.
That file name is configure.cmd
That batch get as a parameter the machine type.
E.g.
configure.cmd -engine
configure.cmd -dmz

Can you please advice what is the best way to execute that batch file using those parameters.
The nearest advice that I found on the forum was: http://www.advancedinstaller.com/forums ... f=2&t=9632 ,but in that topic there is no explanation how to send the machine type parameter.
Thanks.
Nir
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Executing a batch file with parameter

Hello,

In order to achieve this you can use a "Launch File" custom action (added after "Install Execution Stage -> Add Resources" actions group, as deferred) like this:
  • File To Launch: [#configure.cmd]
    Command Line: "parameter"
Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nirs
Posts: 42
Joined: Wed Aug 13, 2014 2:46 pm

Re: Executing a batch file with parameter

Thanks Daniel for your response.
It didn't work for me with parameter.
Let's isolate the problem and try first to execute it directly
E.g. i will run:
configure.cmd -dmz

What should be the exact syntax?

In addition I would like to run the following:
httpd.exe -k install

What should be the exact syntax for that command?

Thanks again.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Executing a batch file with parameter

Hello,

In order to achieve what you want you can add the related files (configure.cmd and httpd.exe) in "Files and Folders" page as regular files and, then use "Launch File" custom actions like this:
  • File To Launch: [#configure.cmd]
    Command Line: "parameter"

    File To Launch: [#httpd.exe]
    Command Line: -k install
Also, you should add the above custom action after "Install Execution Stage -> Add Resources" action group and should run as deferred. If you need to run the above custom action before the "Install Execution Stage -> Add Resources" action group, then you should add the related files as temporary files.

Let us know if this helped, otherwise please give us more details about your scenario (maybe exemplify).

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nirs
Posts: 42
Joined: Wed Aug 13, 2014 2:46 pm

Re: Executing a batch file with parameter

Hi Daniel.

That worked for me for the httpd.exe file.

The issue is that the file configure.cmd is not part of my installation, it is a file that should be located in the target machine before my installation.
How do I launch that file?

Thanks
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Executing a batch file with parameter

Hello,

In order to refer the "configure.cmd" file location, you can use the predefined Windows Installer folder properties. For example if the file would reside in the "C:\MY_folder\" location, then you can set the "File To Launch" field like this:

Code: Select all

[WindowsVolume]MY_folder\configure.cmd
Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”