SSIS - How to run command line to copy files with User Variables within a Execute Process Task

Hello,

I'm am having syntax issues within the Arguments when trying to copy a file with cmd.exe using User Variables.

It works when I hard code the arguments : /c copy /b  "\\folder1\file.txt" "\\folder2\file.txt"

However, it's failing when I try using User Variables to replace the directory and file.

User::FILES = \\folder1\file.txt

User::FILE_NAME = file.txt

"/c copy /b + @[User::FILES] + \" \\\\folder2\\" + @[User::FILE_NAME]"

Does anybody know what's wrong with my syntax?

Thanks!

April 4th, 2014 5:37pm

Hi,

What don't you copy your file with the SSIS File Task component?

Free Windows Admin Tool Kit Click here and download it now
April 4th, 2014 6:02pm

Hello Sebastian,

I could, but I wanted to understand how to use syntax correctly when using user variables in an argument.

Thanks.

April 4th, 2014 6:09pm

Hi SSISBeginner,

Assuming the source file is "C:\Temp\Source\file.txt", the destination folder is "C:\Temp\Destination", the expression of FILES variable is "C:\Temp\Source\file.txt", and the expression of FILE_NAME variable is file.txt. Then, we can use the following expression for the Argument property of the Execute Process Task:

"/C COPY /B "  +  @[User::FILES] + " C:\\Temp\\Destination\\" +   @[User::FILE_NAME]

Note: Pay attention to the spaces in the double quotes in the expression.

Regards,

Free Windows Admin Tool Kit Click here and download it now
April 8th, 2014 3:48am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics