Hello friends, I am back with one more SSIS topic i.e. “Execute process task”. Using this task we can execute batch files and any executable or any command that we execute on command prompt. Lets take a “Execute process task” in control flow region(As shown in the below screenshot).
To configure the “Execute process task”, we will right click on the task and click on “Edit” menu that will bring a new screen in front of us(As shown in the below screenshot).
Lets create a batch file that will be executed using the “Execute process task”, I have created a batch file named “Service.bat”. In batch file, I have written below line that will be executed.
SC STOP SQLWriter à this command will stop the “SQLWriter” service.
In the above window there are number of fields for which explanation is given below.
RequiredFullFileName : by default this property is set to “True” which means task should fail if executable is not found at the specified location.
Execuatable: In this field we define the executable which will be executed.
Arguments: If executable requires an argument to be passed for execution, we pass the argument in this field.
WorkingDirectory: In this field, we specify the location of executable.
StandardInputVariable: We can define input variable to pass to the process task.
StandardOutputVariable: We can define output variable to get output from the process task.
StandardErrorVariable: We can define Error output variable to get error details thrown by process task.
FailTaskIfReturnCodeIsNotSuccessValue: This field tell us whether the task fails if the process exit code is different from the value specified in SuccessValue or not.
SuccessValue: Specify the value returned by the executable to indicate success. By default this value is set to 0.
TimeOut: Specify the number of seconds that the process can run. A value of 0 indicates that no time-out value is used, and the process runs until it is completed or until an error occurs.
TerminateProcessAfterTimeOut: Indicate whether the process is forced to end after the time-out period specified by the TimeOut option. This option is available only if TimeOut is not 0.
WindowStyle: Specify the window style in which to run the process.
Now we will specify the batch file that will be executed by the process task by clicking on the button(encircled by red color) as shown in the below screenshot.
As soon as we click on the button a file open dialogue box will open, we will locate the “service.bat” file and click on “Open” button as shown in the below screenshot.
Since we do not have any argument to pass to the batch file, we will click on “OK” button to save the settings. Now are done with our package, lets execute the package by pressing “F5” key and see the results.
Green color is indicating the success of our package , lets see if the service has stopped or not.
We can see in the service controller UI that “VSS Writer” service is stopped. I hope you will find this article useful. Please feel free to ask any question related to this article.