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.
Thanks,
Chris Dew
Director of Product Management
Interested in SmartConnect? Check out more info here or email us at sales@eonesolutions.com!