The Custom Scripts feature is available in MOVEit Automation Enterprise.
MOVEit Automation custom scripts use Microsoft VBScript. In addition to the basic functions provided by that environment, MOVEit Automation also makes available several application-specific functions.
Functions and Subroutines in Alphabetical Order
For details, see below.
Functions and Subroutines - Details
Adds a file to the list of files to be sent to destinations. CacheFilename is the name of the temporary file to send; you should first call MINewCacheFilename() and create this file. AssignedFilename is the name the file is to be given on the destination server. It may include / or \ characters, in which case the name will be considered a folder path and filename relative to the destination path. Scripts are not currently run on files added via MIAddFile, to prevent infinite loops.
Returns the full path of the directory where MOVEit Automation keeps its temporary files.
Returns the name of the temporary copy of the file. This file can be overwritten if the custom script needs to change the contents of the file before it is transferred.
Returns a string containing the subdirectories and filenames for all active files in the cache. These names are relative to MICacheDir and reflect the actual names on disk in the cache directory, not the original names from the sources. The names are separated by the | character. The last file does not have a | at the end. This list is empty immediately after a call to MIIgnoreFiles. The list does not include, for instance, the names of zip files that have been downloaded from sources marked "Uncompress Archives".
Deletes the specified file, first overwriting it with random bytes. Returns True if successful.
Adds an entry to the FTP or SSH directory listing being parsed. This should be called only from custom directory parsing scripts; see Custom Directory Parsing.
Returns the entire verbatim listing from the FTP or SSH server. This should be called only from custom directory parsing scripts; see Custom Directory Parsing.
Returns the debug level currently set in MOVEit Automation. The possible values are:
Level |
Meaning |
0 |
Internal errors |
10 |
Task/File Errors |
20 |
Task/File Warnings |
30 |
Task Completions |
40 |
File Completions |
50 |
Some Debug |
60 |
More Debug |
70 |
All Debug |
Returns the original filename of the file.
Returns the specified information about the current task. InfoString can have the values:
InfoString |
Value returned by MIGetTaskInfo |
"CacheUsesOriginalNames" |
True if the task is configured to use original filenames in the cache directory, else False if the task is configured to use random filenames. |
"NSources" |
The number of sources in the task. |
"ProcessIsPerFile" |
True if the current process is run for each file, else False if the current process is run once after all downloads. |
"ShouldStop" |
True if an operator has requested that the task be stopped. |
Returns the value of the specified task parameter. If the current task has no such parameter, the empty string is returned.
Causes all files already downloaded or added via MIAddFile to be ignored in subsequent processing steps. For example, use this if your custom script creates a zip file containing the downloaded files, and you do not want the downloaded files to be sent.
Parameter |
Meaning |
---|---|
bDeleteOrigIfCfg |
Whether to delete the original files if the Delete Original File(s) After Successful Transfer option has been set in the source. Default is True. |
bKeepAsNew |
Whether to continue to regard these files as new in the next task run even if the task succeeds. This is meaningful only if Collect Only New Files is set in the source. Default is False. |
Causes the current file to be ignored in subsequent processing steps. For example, call this method if you want your custom script to ignore zero-length files. When called without parameters, this method is equivalent to calling MISetErrorCode 5000. Call this method only in per-file processes.
Parameter |
Meaning |
---|---|
bDeleteOrigIfCfg |
Whether to delete the original file if the Delete Original File(s) After Successful Transfer option has been set in the source. Default is False. |
bKeepAsNew |
Whether to continue to regard this file as new in the next task run even if the task succeeds. This is meaningful only if Collect Only New Files is set in the source. Default isFalse. |
Logs a message to the debug window and debug log file. The message is preceded by the task name.
Evaluates the macro MacroText and returns the resulting text. MacroText may contain any combination of macros.
Returns a new, unique temporary filename. The filename will be a full path and will be in the cache folder
Securely deletes the current temporary cache file, and replaces it with the contents of Filename.
For example, use this to send a different file--probably one you just created--instead of the downloaded file. Typically you first call MINewCacheFilename() to get a filename, use the FileSystemObject to create the file based on the contents of the file in the cache, and then call MIReplaceCacheFile() to tell MOVEit Automation to use the new file.
Runs a system command through the system command interpreter. Command is a command, such as "Notepad MyFile.txt". This can be the name of a command, such as a .exe or .bat file, or the name of a file with an associated extension, such as .vbs, or a built-in CMD.EXE command such as DIR.
MIRunCommand waits until the command is complete. If you want the custom script to continue running while the command runs, use the Windows START command to launch the program.
MIRunCommand returns a long integer: -1 if the program could not be found, or else the return code from the program. Programs typically return 0 upon success, or >0 upon failure.
MIRunCommand does always not work well with pathnames that contain spaces. To avoid these situations, use the "Scripting.FileSystemObject" to look up "safe" versions of paths before passing them to MIRunCommand. For example:
Set fso = CreateObject("Scripting.FileSystemObject")
AppPath = "C:\Program Files\My App"
AppExe = AppPath & "\" & "runit.exe"
SafeAppPath = fso.GetFolder(AppPath).ShortPath
SafeAppExe = fso.GetFile(AppExe).ShortPath
ErrorCode = MIRunCommand(SafeAppExe & " " & " -o " & SafeAppPath & "\out.txt")
Changes the current file's view of one of the task's destinations so that it points to the given configured host. ConfiguredHostName is the name of one of the configured hosts such as "XYZ Corp FTP Server", not an Internet host domain name. The new host need not be the same type as the destination being changed; for instance, the destination may be of type FileSystem, but you can change it to point to an FTP server. Only the current file being processed (if any), and any files added via MIAddFile during this run of the process, are affected.
If you are using this command to switch between hosts of different types (for example, between FTPS and MOVEit Transfer servers) you should also use the "MISetDestPath" command to ensure that destination paths are properly parsed.
Use a value of "(default)" to indicate a Windows file system host; in this case your path value should either begin with a drive letter (e.g., "C:\") or a UNC (e.g., "\\server\share\").
idest is the ordinal number of the destination to change. The default for this optional parameter is 1, which means the first destination in the task. (Most tasks have only one destination.)
Returns an error code which is 0 for success, 2540 if the named host does not exist, or 2850 if idest is out of range.
Changes the current file's view of one of the task's destinations so that it points to a different path. NewPath is the new path or directory name. idest has the same meaning that it does for MISetDestHost. Only the current file being processed (if any), and any files added via MIAddFile during this run of the process, are affected.
Returns an error code which is 0 for success, or 2850 if idest is out of range.
Sets the error code and error description for this process.
If the custom script determines that the file should not be transferred, it should call MISetErrorCode with a non-zero numeric error code and MISetErrorDescription with a textual description of the error. This information will be recorded by MOVEit Automation, and the file will not be sent.
If the special value 5000 is set by MISetErrorCode, MOVEit Automation ignores the file. That is, it does not send the file, does not delete the original file, and does not flag an error that would cause the task to fail. Returning error code 5000 can be used to ignore unwanted files without alarming operators by having the task marked as unsuccessful. See also MIIgnoreThisFile
If the special value 5010 is set by MISetErrorCode, MOVEit Automation does not count this process as having been run. Ordinarily, MOVEit Automation marks a task has having completed successfully (as opposed to "No actions taken") if any process runs, even if no files were downloaded or uploaded. However, if all processes in a task call MISetErrorCode 5010, and no files are transferred, then that task run is considered to have completed with "No actions taken". This affects which NextActions are executed at the end of the task.
Changes the name under which the file should be stored at the destination. The new filename should not contain a path.
Set the status text to be displayed by MOVEit Automation Admin while the script is running. This can be used by long-running scripts to inform the operator the status of the process. If MISetStatus is not called, the message "Running script scriptname" is displayed.
Sets the value of the specified task parameter. If the current task has no such parameter, a parameter of that name is created. Parameter names are not case-sensitive.
Suspends the custom script for the specified number of milliseconds. Very little processor time is consumed during the pause.
Starts the specified task. The first parameter is either a task name (this is checked first) or a task ID. The optional second parameter allows you to specify values for task parameters. If a parameter name matches the name of a parameters configured in the task definition, the new value overwrites the configured value.
The format of TaskParams is ParamName1=ParamVal1|ParamName2=ParamVal2|... The trailing | at the end of the last task parameter is optional.
Example: a task called SendSummaryFile is started with two task parameters computed from within the script: ID
and CheckNum
.
blnResult = MIStartTask("SendSummaryFile", "ID=" & strID & "|CheckNum=" & intCheckNum)
Returns 0 if the task was started. Note: the task will probably still be running when this function returns; a 0 return code does not mean that the task will successfully run to completion.
Returns the name of the task.
Returns the names of the task groups to which the task belongs. This is a string containing the names of all applicable groups, separated by |. For example, the result might be "Daily|For Argus Bank|By Fred", or just "". You can process this in VBScript by creating an array from it using the Split function.