SSIS Execute Process Task

The Execute Process task can be used to run an application or a batch file as one of the steps in an SSIS package. The input, output and arguments of the application can be set in the editor of the task and be used at run-time. For details of the settings in the process page of the editor, you can check it here.

In this section, we'll create a batch file to copy a file from a folder to another location. The destination file name will be saved in a variable to make the process flexible. Before starting to create the package, we'll create a TXT file test.txt and save it in the folder C:\SSIS. Also we'll create a sub folder "work" in the folder to hold the destination copy file of test.txt. At last, a batch file run.bat will be created as following code.

@echo off
copy c:\SSIS\test.txt %1
@echo on

The "%1" is the first argument of the batch file when it runs. After finished all the above, the folder C:\SSIS looks like below.

SSIS Test Folder With Batch File

Not it's time to create the package.

  1. Create a new package in LearnSSIS1 project and rename it to "ExecuteProcessTask.dtsx". Then open the package if it is closed.

  2. Create a variable "destFile" with string type and "xxx.txt" value.

  3. Drag the Execute Process Task from SSIS Toolbox to the control flow of the package.

  4. Right click the task and choose "Edit..." to open the Execute Process Task Editor and then click "Process".

  5. Change the Executable and WorkingDirectory as follows and keep the others as default.
  6. Execute Process Task Editor Process Page Setting

  7. Click "Expressions" and set the property "Arguments" by the variable which was created in step 2.
  8. Execute Process Task Editor Expression Setting

  9. Click the "OK" button twice to save the configuration. Then click "save" icon to save the package and then run it.
  10. After running the package, the file xxx.txt was copied to the working directory "C:\SSIS\work" which was set in the editor.

For Multiple constraints, we'll discuss it in the next section.