0 Comments

When you use NANT to execute a bat file, use the <arg … /> tag to set parameters and use the workingdir to change the current path location, like:

<exec program="CMD.EXE" commandline="/C DatabaseInstallation.cmd" workingdir="${installPath}">
      <arg value="${Database_ServerInstanceName}" />
      <arg value="${Database_Name}"/>
      <arg value="${Database_Domain}"/>
      <arg value="${Database_DtsPackagesFolder}"/>
    </exec>

If you use it like:

<exec program="CMD.EXE" commandline="/C ${installPath}\DatabaseInstallation.cmd" workingdir="${installPath}">
      <arg value="${Database_ServerInstanceName}" />
      <arg value="${Database_Name}"/>
      <arg value="${Database_Domain}"/>
      <arg value="${Database_DtsPackagesFolder}"/>
    </exec>

You will get the exception:

     [exec] ‘C:\Program’ is not recognized as an internal or external command,

     [exec] operable program or batch file.

BUILD FAILED – 0 non-fatal error(s), 2 warning(s)

This can occur even if you use quotes:

<exec program="CMD.EXE" commandline="/C &quot;${installPath}\DatabaseInstallation.cmd&quot;" workingdir="${installPath}">
      <arg value="${Database_ServerInstanceName}" />
      <arg value="${Database_Name}"/>
      <arg value="${Database_Domain}"/>
      <arg value="${Database_DtsPackagesFolder}"/>
    </exec>

One Reply to “NANT task <exec program="CMD.EXE" exception:”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts