[Automation] External Batch File & Variables - Not working

For some reason, I cannot seem to get an external batch file to “take” variables that I’m passing to it from the “Run Program” automation activity.

Here’s the setup:

Program: …\BSR\BSRXH\West_SP_Copy.bat
Arguments: #Yr# “#Mth#” #Date# #Date-15#

#Mth# is surrounded by quotes because it resolves to 02 FEB, and Windows doesn’t allow a space in the file name path that isn’t surrounded by quotes.

And here’s the batch file:

XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2"\05 D PND NO XFER “%3”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2"" /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2"\05 D PND XFER “%3”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2"" /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2"\05 D CMP “%4”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2"" /I /Y

XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2"\32 D PND NO XFER “%3”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2"" /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2"\32 D PND XFER “%3”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2"" /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2"\32 D CMP “%4”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2"" /I /Y

XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2"\09 D PND NO XFER “%3”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2"" /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2"\09 D PND XFER “%3”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2"" /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2"\09 D CMP “%4”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2"" /I /Y

%1 is mapped to #Yr#
%2 is mapped to #Mth#
%3 is mapped to #Date#
%4 is mapped to #Date-15#

When I run this manually from the command line, passing the real values to the batch file, it works perfectly. But when run from the “Run Program” activity - nothing happens. TDA reports that the program exited successfully, but no files are actually copied to the remote directory.

Is there something I’m just missing?

I’ve both simplified this a bit and made it slightly more complicated - again, it runs just fine when calling from the command line and passing the data that would be in the variables:

Program: C:\Automation\West_SP_Copy.bat
Arguments: #Yr# #b_mm# #b_mon# #Date# #Date-15#

And here’s the batch file:

XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2" “%3”\05 D PND NO XFER “%4”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2" “%3"” /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2" “%3”\05 D PND XFER “%4”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2" “%3"” /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2" “%3”\05 D CMP “%5”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2" “%3"” /I /Y

XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2" “%3”\32 D PND NO XFER “%4”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2" “%3"” /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2" “%3”\32 D PND XFER “%4”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2" “%3"” /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2" “%3”\32 D CMP “%5”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2" “%3"” /I /Y

XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2" “%3”\09 D PND NO XFER “%4”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2" “%3"” /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2" “%3”\09 D PND XFER “%4”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2" “%3"” /I /Y
XCOPY “\FILESERVER\IS\REPORTS”%1"\XH"%2" “%3”\09 D CMP “%5”.xlsx" “\SHAREPOINT\REGION\IS\DSR\XH\West”%1""%2" “%3"” /I /Y

%1 is mapped to #Yr#
%2 is mapped to #b_mm#
%3 is mapped to #b_mon#
%4 is mapped to #Date#
%5 is mapped to #Date-15%

This is getting quite frustrating - I don’t get any error messages from Toad, but yet this will not work in the “Run Program” activity.

Further testing yielded a log file that shows that the XCOPY command is being issued from the batch file - however, it appears as though it’s not actually being run - I’m not sure if this is because of how TDA executes the batch file or what.

I know that the batch file is good, because if I run it by hand and pass the parameters along, it works perfectly.

What am I missing?

hi,

You should try to use “find and replace” automation module to write variables directly in the batch file before running it…

Regards.

For some reason variables in a Run activity are working fine in development build but are not in release/beta build. We’re investigating it. Suggested using of Find&Replace activity to substitute values in batch file might be a possible workaround.

Igor.