Loop Processes Action

Declaration

<AMLOOP TYPE="PROCESSES" RESULTVARIABLE="text" [variablename]" KEEPPATHS="yes/no" INCLUDE="text" EXCLUDE="text" SORT="text[options] "RESULTDATASET="text">
  (block of steps to loop)

See Also

Loop Processes Action-Setting Properties, Loop, End Loop, Loop Files, Loop Windows, Loop Expression, Loop Dataset, Loop List, Break

Description

Loops through the filenames of the processes (applications) that are currently running on the system. The variable specified is updated with the process filename. With each successive loop, the next process filename is retrieved. The loop ends after all the process filenames have been retrieved or when a Break is encountered.

Practical Usage

To perform an action on every process (application) open on the system.

Parameters

General Tab

Populate Variable with Process Name

Text, Required
MARKUP: RESULTVARIABLE="varname"

Specifies an already created variable name that should be populated with the next process name on each successive loop. The variable must be created in an earlier step using the Create Variable action.

Do Not Include Path Information

Yes/No, Optional, Default: No
MARKUP: KEEPPATHS="yes"

Specifies that the folder path should be removed from the return value so that a filename only (the process name) is returned.

Create and Populate Dataset with Extended Process Information

Text, Optional
MARKUP: RESULTDATASET="DatasetName"

Specifies the name of a dataset to be created and populated with process data. In addition to the standard dataset fields, the dataset will contain the following:

Advanced Tab

Include Processes

Text, Optional, Default: {blank—include all)
MARKUP: INCLUDE="*notepad.exe"

Specifies the wildcard mask that should be included in the loop. For example, if *notepad.exe was specified, the loop would only include processes with the name notepad.exe, in other words, all open instances of Notepad regardless of the folder they were launched from or whether or not they were displayed. Standard wildcard characters * and ? are allowed.

Exclude Processes

Text, Optional, Default: {blank—include all)
MARKUP: EXCLUDE="*notepad.exe"

Specifies the wildcard mask that should be excluded from the loop. For example, if *notepad.exe was specified, the loop would exclude all processes with the name notepad.exe. Standard wildcard characters * and ? are allowed.

Output List

Text [options], Optional, Default: "none"
MARKUP: SORT="ascending"

Specifies whether a sort order should be applied to the values before the loop begins. For example, selecting "ascending" would return the process names in alphabetical order.

The available options are:

Notes

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

<!-- Closes all Notepad processes -->

<AMVARIABLE NAME="currentprocess"></AMVARIABLE>

<AMLOOP TYPE="PROCESSES" RESULTVARIABLE="currentprocess" INCLUDE="*notepad.exe" RESULTDATASET="ProcessDataset">

     <AMENDPROCESS PROCESS="%currentprocess%" />

</AMLOOP>