This is a step-by-step example that shows how you can pass a variable to the Executable property of Execute Process Task. The example was created using SSIS 2008 R2 and also uses three .bat files to illustrate the functionality. Even though the example is in SSIS 2008 R2, the logic should be applicable to SSIS 2005.
Create three .bat files namely Process_0.bat, Process_1.bat and Process_2.bat. Refer screenshot #1. Populate them with echo commands as shown
Create the following variables: Refer ScreenShots
- ExecutableFileName – This variable is of type string. It will contain the executable file name.
- ExecutableFolder – This variable is of type string. It will contain the executable file’ folder path.
- ExecutableFilePath – This variable is of type string. Do not key in any value for this variable. This will be an expression that combines the variables ExecutableFolder and ExecutableFileName to generate the full file path. Refer screenshot #7. Select the variable and press F4 to open the properties window. Set EvaluateAsExpression to
Trueand set the Expression to
@[User::ExecutableFolder] + @[User::ExecutableFileName]
- ExecutableOutput – This variable is of type string. It will store the executable’s output value. In this case, the value echoed by the .bat files.
On the package’s control flow path, place Execute Process Task and a Script Task as shown in screenshot
Configure the Execute Process Task as shown in screenshot below On the Process section of the Task, you need to specify an Executable path for initial configuration. Also, specify the StandardOutputVariable (this is for this example). On the Expressions section, override the Executable path by specifying the variable @[User::ExecutablePath]
On the Script Task, replace the Main method as shown in screenshots
Execute the package. You should get the output as shown in screenshot It shows the .bat file Process_0.bat was executed with the output
Now, change the value of the variable ExecutableFileName to Process_1.bat. Do not make any other changes. Execute the package. You should get the output as shown in screenshots . It shows the .bat file Process_1.bat was executed with the output
Now, change the value of the variable ExecutableFileName to Process_2.bat. Do not make any other changes. Execute the package. You should get the output as shown in screenshots . It shows the .bat file Process_2.bat was executed with the output