Close Process

Verb: closeProcess

Available from: <Standard>

Terminates a running process according to its Id and Name.

A process consists of an instance of a computer program that is running.

Syntax

closeProcess --by(ProcessBy) --id(Numeric) [--useRegex(Boolean)] --name(String) --regexPattern(String) [--regexOptions(DisplayableRegexOptions)] [--sessionsearch(Nullable<ProcessSessionSearch>)] --sessionid(Numeric) [--timeout(TimeSpan)] (Boolean)=value

Inputs

Script Designer Required AcceptedTypes Description
--by Find by Required ProcessBy Selector type to find the process. The following options are available:
  • Id
  • Name
  • --id Id Only whenFind by is Id Number Id of the process.
    --useRegex Use regular expression Optional Boolean Enables searching for the process using a regular expression.
    --name Process name Only whenUse regular expression is False Text Name of the process.
    --regexPattern Regular expression Only whenUse regular expression is True Text Regular expression used to find the process.
    --regexOptions Options Optional DisplayableRegexOptions Regular expression options. You can select more than one of the following:
  • Compiled
  • Culture Invariant
  • ECMA Script
  • Explicit Capture
  • Ignore Case
  • Ignore Pattern Whitespace
  • Multiline
  • Right To Left
  • Singleline
  • --sessionsearch Session search directive Optional ProcessSessionSearch Session in which the process should be searched for.
  • All Sessions
  • Current Session
  • Specified Session
  • --sessionid Session id Only whenSession search directive is SpecifiedSession Number Id of the session that should be fetched.
    --regex Use regular expression(Obsolete) Optional Boolean When enabled, allows the use of a "Regular Expression" to search for the process.
    This parameter is obsolete, the Use regular expression parameter should be used instead.
    --ignorecase Ignore case(Obsolete) Optional Boolean When enabled, specifies case-insensitive matching.
    This parameter is obsolete. To select regular expression options, use the Options instead.
    --dotmatchesnewline Dot matches new line(Obsolete) Optional Boolean When enabled, the dot (.) character matches every character, instead of every character except "\n".
    This parameter is obsolete. To select regular expression options, use the Options instead.
    --freespacing Ignore white space(Obsolete) Optional Boolean When enabled, eliminates blank spaces and breaks without adding a escape character.
    This parameter is obsolete. To select regular expression options, use the Options instead.
    --explicitcapture Explicit capture(Obsolete) Optional Boolean When enabled, specifies that the only valid captures are explicitly named or numbered groups of the form (? ).
    This parameter is obsolete. To select regular expression options, use the Options instead.
    --multiline Multiline(Obsolete) Optional Boolean When enabled, changes the meaning of ^ and $ so they match at the beginning and end, respectively, of any line, and not just the beginning and end of the entire string.
    This parameter is obsolete. To select regular expression options, use the Options instead.
    --timeout Timeout Optional Time Span, Number, Text Maximum wait time to find the process.
    In case no value is defined for the timeout parameter, the execution uses the context timeout defined by the Set Timeout command. If that command is not used on the script, the default timeout is 5 seconds.

    Outputs

    Script Designer AcceptedTypes Description
    value Success Boolean "True" if the process is terminated successfully or "False" if otherwise.

    Example

    Launch a Notepad with the Launch and Attach Window command and stores the output of this command, which corresponds to the process ID. After that, we use Close Process to find and close the process with the obtained ID.

    defVar --name processClosed --type Boolean
    defVar --name processID --type Numeric
    launchWindow --executablepath "notepad.exe" processID=processId
    closeProcess --by "Id" --id ${processID} --timeout 00:00:20 processClosed=value
    //Displays in the console whether the process has been closed correctly.
    logMessage --message "Process closed: ${processClosed}" --type "Info"
    

    Remarks

    In the Regular expression parameter, you can use the Regular Expression Editor via the toolbar in the Tools menu or by clicking on the editor icon in the command interface.

    See Also

  • Check if Process Exists
  • Wait for Process