Core Function ProcessExists

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> ProcessExists( <pid/name> ) </pre> === Description === Checks to see if a specified process exists. === Parameters === ==== pid/name ==== The name or PID of the proce...")
 
(Return Value)
 
(4 intermediate revisions by one user not shown)
Line 17: Line 17:
 
Success: Returns the PID of the process.
 
Success: Returns the PID of the process.
  
Failure: Returns 0 if process does not exist.
+
Failure: Returns @IntPtrZero if process does not exist.
  
 
=== Remarks ===
 
=== Remarks ===
Line 23: Line 23:
 
Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"
 
Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"
  
If multiple processes have the same name, the one with the highest PID is terminated--regardless of how recently the process was spawned.
+
If multiple processes have the same name, the one with the highest PID is returned--regardless of how recently the process was spawned.
  
 
PID is the unique number which identifies a Process.
 
PID is the unique number which identifies a Process.
 
A PID can be obtained through the ProcessExists or Run commands.
 
 
In order to work under Windows NT 4.0, ProcessClose requires the file PSAPI.DLL.
 
 
The process is polled approximately every 250 milliseconds.
 
  
 
=== Example ===
 
=== Example ===
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
If (ProcessExists("notepad.exe"))
+
If ($PID = ProcessExists("notepad.exe"))
 
{
 
{
     MsgBox("Notepad is running.");
+
     MsgBox("Notepad is running and its PID is '$PID'");
 
}
 
}
 
else
 
else
Line 44: Line 38:
 
     MsgBox("Notepad not is running.");
 
     MsgBox("Notepad not is running.");
 
}
 
}
ProcessWaitClose($PID)
 
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Latest revision as of 19:54, 14 June 2015

ProcessExists( <pid/name> )

Contents

Description

Checks to see if a specified process exists.

Parameters

pid/name

The name or PID of the process to check.

Return Value

Success: Returns the PID of the process.

Failure: Returns @IntPtrZero if process does not exist.

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"

If multiple processes have the same name, the one with the highest PID is returned--regardless of how recently the process was spawned.

PID is the unique number which identifies a Process.

Example

If ($PID = ProcessExists("notepad.exe"))
{
    MsgBox("Notepad is running and its PID is '$PID'");
}
else
{
    MsgBox("Notepad not is running.");
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox