Command-line Operation

Introduction

Occasionally users may have a need to run a task created in AutoMate from outside of AutoMate - usually the user wishes to run the task from one of the following: a batch file, an external program, the command line. The files SpawnTask.exe and SpawnTaskCMD.exe (collectively SpawnTask) exist for this purpose and can be found in the AutoMate folder, which is installed by default under “c:\Program Files\AutoMate 5\”.

How to use Spawntask

Once started, SpawnTask does not end until the task (specified on the command-line parameter) has finished processing, once finished - SpawnTask returns 0 if the task fails to finish properly and 1 if the task was successful.

Command Line Options

SPAWNTASK accepts several command-line parameters to control its operation.

taskname: The filename of the task to run. If the task file name includes spaces - it should be surrounded in quotes or improper operation will result. The 1st parameter must be “taskname”.

/v:varname1=value1 - Specifies variable(s)/value(s) to pass to the task. Format is semi-colon delimited name=value pairs.

Example 1
: /v:varname1=value1;varname2=value2;varname3=value3.

Since the list is semi-colon delimited, semi-colons are not allowed in the variable name or value to pass. This can be worked around by replacing a semi-colon with another special character before passing it to SpawnTask and configuring the task to replace it back to a semi-colon at run time using an embedded expression in the task. For example, if an exclamation point were used as a replacement character for a semi-colon, a Set Variable action at the beginning of your task using the expression Replace$(var1, "!", ";") as the new variable data would convert the exclamation points back to semi-colons.

/? - Causes SpawnTask to display a message box with usage and syntax help.

The Difference Between SpawnTask.exe and SpawnTaskCMD.exe

The two files SpawnTask.exe and SpawnTaskCMD.exe work exactly the same with the exception of one characteristic. SpawnTask.exe is a pure Windows application and is designed to run a task and return to a Windows application when the task specified has been completed, whereas SpawnTaskCMD.exe what is called a “console application” and is designed to be run from a command prompt or batch file.

Why two files?

Simple… True windows applications will return immediately when run from the command prompt regardless of when they actually finish running; thus, using the original SpawnTask.exe one would not be able to determine when the launched task finished or get a return code to determine it’s success or failure. To avoid this behavior, use SpawnTaskCMD.exe, which is designed for use in a console (command line or batch-file) environment.

The next question is: why not always use SpawnTaskCMD.exe then? This is also simple - because when SpawnTaskCMD.exe (a console application) is invoked from a true Windows application (not from the command prompt) it would then cause a command prompt (AKA DOS box) to appear if one was not already open. This is not visually appealing and can confuse users. So the simple rule to remember is:

SPAWNTASK.EXE - when launching from a Windows application, macro/script, or windows itself.

SPAWNTASKCMD.EXE - when launching from the command prompt, a DOS based application or most importantly, a batch file.

Syntax Examples:

Get help

 "C:\Program Files\AutoMate 5\SpawnTask.exe" /?

Run a task

"C:\Program Files\AutoMate 5\SpawnTask.exe" "C:\Documents and Settings\All Users.WINDOWS\Documents\My AutoMate Tasks\check email.aml"

Run a task and pass variables

"C:\Program Files\AutoMate 5\SpawnTask.exe" "C:\Documents and Settings\All Users.WINDOWS\Documents\My AutoMate Tasks\check email.aml" /v:VARNAME1=VALUE1,VARNAME2=VALUE2

If using SpawnTask from a batch file or other command prompt source use SpawnTaskCMD.exe instead of SpawnTask.exe all command line options are the same.