User Community Service Desk Downloads
If you can't find the product or version you're looking for, visit support.ataccama.com/downloads

Run Windows Command

Run Windows Command icon

Executes a Windows command: use it only for Windows operations. For Linux operations, use Run Shell Script.

Properties

Name Type Description Expression support

Command

mandatory

Command to execute. See How is the command processed?.

semi-expression

Working Dir

optional

Working directory. Default value: the current Java process directory (usually value of usr.dir property).

semi-expression

Wait For

optional

Defines whether the task should wait until the job finishes. Default: true.

none

Expected Return Codes

optional

Comma-separated list of integer values representing valid return codes of the command. Default: 0.

none

Log Start Stop

optional

If set to true, the task writes start and stop marks to the standard output log (STDOUT). Default: true.

none

How is the command processed?

  1. The possible variable mapping replacements are performed.

  2. An EXIT %ERRORLEVEL% instruction is added to the end of the command.

  3. The entire command value is copied to the temporary script file.

  4. The temporary script file is executed using cmd.exe (you can find the temporary script in the task resources directory). Using the intermediate temporary script file allows the user to define more sophisticated interpreter-related logic.

Wait For modes

  • waitFor=true

    1. The task waits until the run command is done.

    2. The returned code is then compared against expectedReturnCodes.

    3. If expected codes do not contain the returned code, the task fails.

  • waitFor=false

    1. The task only starts up the command and then terminates immediately.

    2. That means that there is no valuable return code to compare against expectedReturnCodes, therefore this comparison is skipped.

    3. The task finishes in OK state and the result of the task is set to -1 ("unknown" value).

Notes

When you call other scripts from your command, remember to invoke them using the call syntax (for example, call some_script.bat). Otherwise, the called script:

  • Does not return control to the caller once it is done.

  • Does not store the return value to the OS ERRORLEVEL property.

Both of these situations prevent correctly setting the result code.

Predefined variables

  • SCRIPT_RESULT_CODE: Contains the result code returned by the script. The variable is set only if:

    • The task was run with waitFor=true.

    • The task has not failed with exception.

Sample
<executable class="com.ataccama.adt.task.exec.EwfWinCmdTask">
    <command>name</command>
    <workingDir>query</workingDir>
    <waitFor>true|false</waitFor>
    <expectedReturnCodes>0,1</expectedReturnCodes>
</executable>

Use workflow variables in Windows command

If you would like to use workflow variables in a Windows command, use the following syntax:

Workflow variable in Windows command syntax
echo ${workflow_variable_id}

See also the complete example from Workflow Tutorials in ONE Desktop (07_03b_Iterator_Set_Child.ewf).

Complete Example from 07_03b_Iterator_Set_Child.ewf
@echo off
rem this is an example how to reach out the workflow input and system variables in a windows command

set wfl_exec_id=${ewf_execution_id}
set input_var=${COUNT_SEC}

echo "ID of the current workflow instance (execution): " %wfl_exec_id%
echo "Same as above: " ${ewf_execution_id}

echo "Value of the passed input variable: " %input_var%
echo "Same as above: " ${COUNT_SEC}

Was this page useful?