What is the correct way to execute a .bat/.cmd file with parameters?

Hi,

I’m looking for the correct way to run a .bat/.cmd file with parameters in ContinuaCI. The file accepts four parameters and is stored on a Linux network share with the executable bit not set. Therefor Windows does not allow to execute the file directly and I cannot use the “Execute Program” task with the .bat/.cmd file as the application.

The next thing I tried was the “Execute Program” task with “cmd.exe” as the application and although cmd.exe is directly accessible via the PATH environment variable, ContinuaCI checks if a cmd.exe is available in the working directory.

As ContinuaCI provides a “Run DOS Command / Batch File” task I tried that, but the are no options to provide parameters to the batch file and they can’t be included in the path to the batch file.

So, how do I run a parameterized .bat/.cmd file from ContinuaCI?

With kind regards

Kay Zumbusch

Hi Kay,

You can include parameters in the “Command or Batch File” field of the “Run DOS Command / Batch File” action.

e.g.

The batch file “echoParams.bat” contains the following lines:

@echo parameter1=%1
@echo parameter2=%2
@echo parameter3=%3

The build log shows the output as follows:

image