Loop - Processes

Declaration

<AMLOOP ACTIVITY="processes" DOMAINNAME="text" REMOTEMACHINE="text" USERNAME="text" PASSWORD="text (encrypted)" RESULTVARIABLE="text" RESULTDATASET="text" KEEPPATHS="yes/no" INCLUDE="text" EXCLUDE="text" SORT="text (options)" />

Related Topics   

Description

Loops through the processes (applications) that are currently running on the local system or remote machine and populates a variable with the file name of the current process. With each successive loop, the next process file name is retrieved. The loop ends after all the process file names have been retrieved or when a Break is encountered. Optionally, a dataset can be populated with extended process information. This activity supports scanning.

Practical usage

Mainly used to perform one or more activities on one or more processes (applications) running on the system. For example, an administrator can retrieve the process ID of each instance of a running process. This number may be used as a parameter in various function calls allowing processes to be manipulated, such as adjusting the process's priority or killing it altogether.

Parameters

General

 
PropertyTypeRequiredDefaultMarkupDescription
Store process name in variableTextYes(Empty)RESULTVARIABLE="varname"The name of an existing variable that should be populated with the next process name on each successive loop.
Discard path informationYes/NoNoNoKEEPPATHS="yes"If enabled, the folder path is removed from the return value so that only the file name is returned (for example, iexplore.exe). This parameter is disabled by default.
Create and populate datasetTextNo(Empty)RESULTDATASET="DSName"The name of a dataset to be created and populated with process data. In addition to the standard dataset fields, this dataset will contain the fields specified below under Datasets.

Advanced

 
PropertyTypeRequiredDefaultMarkupDescription
Include processesTextNo(Empty)INCLUDE="*Explorer"Indicates a wildcard mask to designate the process names to be included in the loop. Asterisk (*) or question mark (?) can be used as wildcard characters. For example, if *explorer* was entered, this activity would loop only processes that contains the text 'explorer' in its name. To specify multiple wildcard masks, separate each one with a pipe (|) character (*.txt|*.jpg).
Exclude processesTextNo(Empty)EXCLUDE="*Explorer"Indicates a wildcard mask to designate the process names to omit in the loop. Asterisk (*) or question mark (?) can be used as wildcard characters. For example, if *notepad* was specified, the loop would omit processes that include the text notepad in its name. To specify multiple wildcard masks, separate each one with a pipe (|) character (*.txt|*.jpg).
Pre-sort listText (options)NoDo not sortSORT="ascending"Specifies the sort order that should be applied towards the list of processes before the loop begins. The available options are:
  • Do not sort - No sorting will be applied.
  • Ascending alphabetical order - The list will be sorted in ascending alphabetical order (A-Z).
  • Descending alphabetical order - The list will be sorted in descending alphabetical order (Z-A).

Computer

 
PropertyTypeRequiredDefaultMarkupDescription
Local computer------------If enabled, specifies that the processes to loop resides on the local machine. This parameter is enabled by default. If this parameter is selected, the Another computer parameter becomes inactive. This is a visual mode parameter used during design time only, therefore, it contains no markups.
Another computer------------If enabled, specifies that the processes to loop resides on a remote machine. The parameters below become active if this parameter is enabled. This is a visual mode parameter used during design time only, therefore, it contains no markups.
ComputerTextYes(Empty)
  • REMOTEMACHINE="pcname.domain.com"
  • REMOTEMACHINE="xxx.xxx.xxx.xxx"
The hostname (computername.domain.com) or IP address (xxx.xxx.xxx.xxx) of the remote machine where the processes to loop resides. This parameter is available only if the Another computer parameter is enabled.
DomainTextYes(Empty)DOMAINNAME="netauto"The domain name of the remote machine where the processes to loop resides. This parameter is available only if the Another computer parameter is enabled.
UsernameTextYes(Empty)USERNAME="Bruce.Wayne"A valid username used to log onto the remote machine in which the processes to loop resides. This parameter is available only if the Another computer parameter is enabled.
PasswordTextYes(Empty)PASSWORD="encrypted"The password corresponding to the username entered in the Username field. This parameter is available only if the Another computer parameter is enabled.

Description

Error Causes

On Error

Additional notes

Datasets

A dataset is a multiple column, multiple row container object. This action creates a dataset table with the information listed below (assuming the dataset name selected is theDataset):

NameData TypeReturn Value
theDataset.ProcessNameTextReturns the path and file name of the .exe file of the process.
theDataset.ProcessIDNumberReturns the unique ID of the process.
theDataset.WindowTitleTextReturns the title of the main window associated to the process.
theDataset.WindowClassTextReturns the class of the process's main window. A window class is a set of attributes that the system uses as a template to create a window.
theDataset.WindowHandleNumberReturns The handle of the process's main window. A window handle is a code that uniquely identifies the window.

Example

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Description

This task closes all currently open Notepad processes. In order for this task to work properly, make sure to have one or more instances of Notepad open on the desktop.

Copy
<!-- Closes all Notepad processes -->
<AMVARIABLE NAME="currentprocess" VALUE="" />
<AMLOOP ACTIVITY="processes" RESULTVARIABLE="currentprocess" RESULTDATASET="ProcessDataset" INCLUDE="*notepad.exe" />
<AMPROCESSES ACTIVITY="end" PROCESSNAME="%currentprocess%" />
<AMLOOP ACTIVITY="end" />