Passing Argument from Execute Process Task (SSIS) to a Batch File
Hi, I have a batch process set up, which executes fine as long as the name of the file is built in. My Execute Process task in SSIS also runs this batch file with succes. I would like to pass the name of the file as a parameter from the Task (SSIS) to this batch file. Looks like I am doing something wrong because it is failing. This is the batch file: C: cd \Program Files\WS_FTP Pro\ wsftppro -s "local:D:\Folder1\Folder2\%1" -d HDMS:/To_HDMS/ --- The %1 is the parameter The argument that I am passing in is in the 'StandardInputVariable' Would really really appreciate some help! Thanks so much! Vicky
November 16th, 2010 10:50am

Please post more information. Specifically: How have you currently configured the Execute Process Task? What error messages do you get/how do you know it's failing? Talk to me now on
Free Windows Admin Tool Kit Click here and download it now
November 16th, 2010 12:23pm

Hi, the message that I get when the SSIS task fails is: [Execute Process Task] Error: In Executing "D:\Folder1\Folder2\Process.bat" "FileName.txt" at "", The process exit code was "1" while the expected was "0". Process.bat is the batch file FileName.txt is the parameter I am sending in. Vicky
November 16th, 2010 2:15pm

Please provide more details about how you have configured the task. Please list the properties in the UI, and the values you've given them. From what you've provided so far, it appears as though the command simply can't be executed because the command line generated is illegal, or your batch file is returning a code of "1". Talk to me now on
Free Windows Admin Tool Kit Click here and download it now
November 16th, 2010 9:51pm

The task has an Expression in it that combines a user defined variable (the file name) with current date. That string is the parameter that I am trying to pass in to the batch file. In the 'Executable' line is the path to the batch file with the name of the batch file in it. Thanks so much for your help!Vicky
November 17th, 2010 10:28am

Hi Vicky, Don't pass your parameter in the 'StandardInputVariable' property. Instead, pass it as a parameter in the 'Arguments' property. So, in the Expressions page of the Execute Process Task's property window, have an expression for the 'Arguments' property. Set it to your package variable that has the filename and the datetime concatenated to it. Remove the expression for the 'StandartInputVariable' property. Try! Let us know in case it doesn't work. Cheers, ShalinShalin P. Kapadia
Free Windows Admin Tool Kit Click here and download it now
November 17th, 2010 12:24pm

Hi, did that, looks good, thanks! Now how do I indicate it in the batch file? This is what I have there so far: C: cd \Program Files\WS_FTP Pro\ wsftppro -s "local:D:\Folder1\Folder2\FileName" -d HDMS:/To_HDMS/ Need to replace that FileName with the parameter. Thank you!!!!Vicky
November 17th, 2010 2:25pm

Create 2 variables in your SSIS package. The first one would have the FileName along with the entire path. The other variable will have its property 'Evaluate As Expression' set to TRUE and set its Expression to the following - "local:" + @[System::FilePathVariable] + " -d HDMS:/To_HDMS/" As soon as the second variable is referenced in your SSIS package, its expression (the one written above) would execute. Say the FilePathVariable had the value "D:\Folder1\Folder2\FileName"; so, the value of the second variable after its expression is evaluated would be "local:D:\Folder1\Folder2\FileName -d HDMS:/To_HDMS/" You need to pass this as an argument to your batch file. This would be done as explained in my previous post above. In your batch file, have the command as - C: cd \Program Files\WS_FTP Pro\ wsftppro -s %1 I haven't tried this. Please try and let us know in case it doesn't work for you. Cheers, ShalinShalin P. Kapadia
Free Windows Admin Tool Kit Click here and download it now
November 17th, 2010 9:24pm

Hi Vicky, The issue "Error: In Executing "D:\Folder1\Folder2\Process.bat" "FileName.txt" at "", The process exit code was "1" while the expected was "0"." may be caused by that you used double quotes around the D:\Folder1\Folder2\Process.bat. To solution the issue, please follow these steps: Set the Executable to be: C:\Windows\System32\cmd.exe Set the Arguments to be: /c D:\Folder1\Folder2\Process.bat "FileName.txt" Another way to solve the issue is: Set the Executable to be: D:\Folder1\Folder2\Process.bat Set the Arguments to be: "FileName.txt" There is similar thread for your reference, this will help you too: http://social.msdn.microsoft.com/Forums/en/sqlintegrationservices/thread/0907abb3-ed84-4f85-ae37-c87539d7776f If you have any more questions, please feel free to ask. Thanks, Jin Chen Jin Chen - MSFT
November 17th, 2010 9:35pm

Shalin, it fails with: [Execute Process Task] Error: In Executing "D:\Folder1\Folder2\BatchFile.bat" "local:D:\Folder1\Folder2\FileName.txt" at "", The process exit code was "13" while the expected was "0". Do you have any idea what that at "'" is? Thanks so much for helping me out. Vicky
Free Windows Admin Tool Kit Click here and download it now
November 19th, 2010 9:52am

Shalin, great news, it worked!!! You have absolutely put me on the right path, thank you so much!!! I made a few minor changes though: the second variable is set as an argument of the Task, (in the expression), and put this into it: "\"local:" + @[System::FilePathVariable] Left the -d HDMS:/To_HDMS/ part out, because that does not have to be in quotes. Also I will separate the file name from the file path, because the FileName will be changing, and then catcatinate those two variables. Again, thanks so much!!! THE ISSUE WAS THE QUOTES!!!!!!!!!!Vicky
November 19th, 2010 10:12am

Hi, Do you think you can help with my issue? See below thread... http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/f954e169-88fa-4119-917f-852fc74b7b46/
Free Windows Admin Tool Kit Click here and download it now
February 22nd, 2011 9:33am

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

Other recent topics Other recent topics