Process Commands

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Process Operations >

Process Commands

IEP. / NEP. - If-Exists-Process

Previous Top Next


MiniRobotLanguage (MRL)

 

IEP. Conditional Statement

If Exist Process

 

 

Intention

 

Conditional Statement. Test if a specified process is running.

 

IEP.x64.exe

  MBX. Process ID is: #pid#

EIF.

 

If you have multiple EXE running with the same name, you can specify a number. If the EXE is found, the #pid# is set to the EXE's Process-ID. Please note that #tid# is always set to zero.

 

You can specify a full path, or only the filename or a part of it. If you search for a dll, then the extension ".dll" must be included in the pattern.

 

You can use NEP.,  the negative Form of this command (NEP. - Not Exists Process).

 

If a process is found, valuable information is placed on the actual stack. These include the full name and path of the found executable.

 

ifexistprocessb1

 

Below are two snapshots of the windows-taskmanager. Skype.exe has the PID (process-id) 4600. Its on the stack on position 02 in the picture above.

The 2312  which is on position 01 (picture above) is the parent-process, that is the process which has started skype.exe.

In the task manager, we can see that this is the PID of the windows-explorer. This way you can find out which process has started another process.

 

If you give IEP. a variable as third parameter, then the stack will not get the full path of the found file. You will find it in the given variable instead.

 

Please note that the 2.4 The global and local Stack as Que or as Stack will influence the sequence in which the items appear on the stack.

 

graphic graphic

 

You can also use IEP. to verify, if a process with a specified PID is alive or not.

To do this, the Syntax is:

 

STS.GLOBAL

IEP.>1234

  MBX.PID 1234 (Filename=$$000) is alive!

EIF.

 

You can use IEP. also to check if one or one of many PID's is alive or is not alive.

There two Modes where you can give a PID as parameter and test if this process is alive.

 

You  can read more details on how IEP works in the chapter 1.7. Application and PID.

 

 

Syntax

 

 

IEP.P1[|P2][|P3]  … ELS. … EIF.

 

 

 

Parameter Explanation

 

There are two Usage Mods.

 

"If_exist_Process-Mode":

P1 - Variable/Exe-/DLL-Filename, with or without path. Pattern can be used.

 

P2  - Variable/Number/Formula - Number of result (take fist, second   etc. fitting result)

 

P3  - Variable if given gets the full path of the found exe/dll

 

"Is_Process_Alive-Mode":

P1 - Starting with a ">"-Sign this indicates that we are in this Mode. Now follow one or more PID's separated by ",". The rule is: if ONE of these PID's is alive, the data of this process is been place on stack, and the condition evaluates to true. Only if none of the given PID's is alive the condition evaluates to false.

In this Mode you'll find some information about the process that is alive on the stack. See following picture. On TOS you see the full path of the process. And below you see the PID of the process.  Also #pid# is set to the alive process.

 

' Example "Is process alive Mode"

IEP.>$$PIA,$$PIB,$$PIC

...

EIF.

 

graphic

 

 

"Is_Process_Dead-Mode":

P1 - Starting with a "<"-Sign this indicates that we are in this Mode. Now follow one or more PID's separated by ",". The rule is: if ONE of these PID's is NOT alive, then the PID of this process is been place on stack, and the condition evaluates to true. Only if all of the given PID's are alive then the condition evaluates to false. Also #pid# is set to the last process that was found alive. If multiple PID's given and the first one is dead, #pid# is not changed.

 

' Example "Is process dead Mode"

IEP.<$$PIA,$$PIB,$$PIC

...

EIF.

 

The negative Form of IEP. is NEP. NEP. is available for all Modes above.

 

 

Example

 

'***********************************

' IEP.-Demo (IsProcess Alive)

'***********************************

' This first IEP. Shows the normal Mode, we ask for

' a specified process to exist

' we will get the PID of that process into #pid#

IEP.Explorer.exe

 ' Now we have a valid PID

 : $$PID=#pid#

 ' Now we can test if the PID is "alive"

 IEP.>$$PID

   DBP. The Process $$000 is alive

 EIF.

EIF.

ENR.

 

'***********************************

' IEP.-Demo (IsProcess dead)

'***********************************

' We use a Search-Pattern this time

IEP.{{Ex&THEN:rer.exe}&OR:Explo}

 : $$PID=#pid#

 ' Now we have a valid PID

 ' Now we can test if the PID is not alive

 IEP.<$$PID,99,45,34,222

   DBP. At least one of the Processes 99,45,34,222 is not alive

   DBP.Its PID:$$000

 EIF.

EIF.

ENR.

 

 

Remarks

 

The command works transparently with both x32 and x64 applications.

 

IEP. and other IXX. can be nested to unlimited Depth, and they can also enclose Sub-Program Calls or FEX. (Enumerations) to unlimited Depth.

 

 

 

Limitations:

 

no Limitations.

 

 

 

See also:

 

    1.6.1. Program Flow Control

    1.7. Application and PID

    GPI. - Get Process Information

    FEP. - For-Each-Process

    GDF. - Get-Data-From

    WPR. - Wait-Process-Running

    WPT. - Wait-Process-Termination

    3.3 Specialfolders