There are many times when it may be necessary to run a process before or after an integration. I have seen everything from a call to a webservice, FTP of source data, and everything in between. The focus of this post is to talk about running some kind of a file before an integration. We will explore two methods for doing this, the first method is the Run File Task and the second is using a Run Script Task to pass in parameters to the file.

We start in one of our maps and click on the Tasks button. In the Map Pre Tasks section we right click on the Tasks that run before the map section then expand the New Task and choose the Run File to create a new task of this type.

After naming our Task we can then choose the location of the file we want to run. This could be a .bat file, PowerShell script, EXE or even any file that will open with whatever has been associated (ie .docx would open in MS Word, .pdf would open in Acrobat Reader).

One issue that can arise is when you need to pass a parameter into that file. That is where you will need to change the Task Type to a Run Script instead. In the simple example below I am just using the notepad.exe and then passing in the file that I want to open utilizing VB.Net(C# could be used as well but the sample code is VB.Net).

In the text of the script below I have shown you a couple of ways you may want to pass in parameters. They have been commented out but note that one actually has multiple parameters passed in that you may use to run an executable. The other commented out section defining the parameters actually uses a GLOBAL variable that can be defined elsewhere in the map.

‘Specify the location of your filename
Dim filename As String = “c:windowssystem32notepad.exe”

‘Specify the parameters you want to run on that file
‘This passes in one parameter indicating which file should open
Dim fileparameters As String = “file.txt”
‘This passes in multiple parameters to a file
‘Dim fileparameters As String = ” /s /v”
‘This uses a Global Variable to pass in the parameters that were set somewhere else in SmartConnect
‘Dim fileparameters As String = GBL_FILEPARAMETERS

‘This runs the file passing in any parameters you may have specified
System.Diagnostics.Process.Start(filename, fileparameters)

return true

Now you can see that SmartConnect has the flexibility to use the simple standard Run File Task or the power to pass in parameters using the simple script in a Run Script Task above.

Have fun coming up with your own combinations and scripts and let me know if you have suggestions for future topics or want to share what you have done.

Chris Dew
Director of Product Management

Interested in SmartConnect? Check out more info here or email us at!