Writing custom VBS scripts in Tasks
It’s always difficult to decide where to start when writing scripts, however with MOVEit Automation you must always start with the restriction of the scripting language available to you. Custom scripts must be written in one of the core Window Script Host languages, Visual Basic. Whilst this article will attempt to convey some of the things you need to know about MOVEit Automation scripting, it does not include teaching in Visual Basic itself; there are a plethora of teaching guides available on the internet to assist with this.
The first place to start is the Ipswitch Portal. This contains some useful scripts already, which although basic, nevertheless will get you started in the right direction. The next thing to look at is the online documentation; there are 24 subroutines and functions that you can include in a VBS script to allow you to pass information back and forth between MOVEit and the script. For example, to access a file as it comes into the cache use the function MICacheFilename; to replace the outgoing file use the function MINewCacheFilename.
When calling a script, you can pass parameters in the same way as any regular script; you can then access these parameters in the script using the function MIGetTaskParam. Use MILogMsg to write messages out to the log file to keep track of what the script is doing (very useful for debugging while writing the script).
So let’s create a new blank script, give it a name and description:
‘We start by getting the parts of the folder to
‘rename and the folder path itself.
Source = MIGetTaskParam(“Source”)
Dest = MIGetTaskParam(“Dest”)
FullPath = MIMacro(“[FullPath]”)
‘The FullPath macro unfortunately contains
‘the filename, which we need to remove:
OrigName = MIMacro(“[OrigName]”)
FullPath = Replace(FullPath,OrigName,””)
‘Now we update the folder path with the new name
NewPath = Replace(FullPath,Source,Dest)
MyResult = MISetDestPath(NewPath)
‘Write out a log message and result
MILogMsg “changed ” & FullPath & ” to ” & NewPath & “ RC” & MyResult
(Please note: All screenshots have been taken from MOVEit Central Enterprise Edition 8.0)
Need Additional UK-Based MOVEit Training and Support?
Not only are Pro2col a certified Gold Partner, Ipswitch named us as their UK File Transfer Partner of the Year! Our MOVEit technical team are here to help you get the most out of your solution.