Core Function ProcessWaitClose

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> ProcessWaitClose( <pid/name>, <timeout> ) </pre> === Description === Pauses the current thread until a given process no longer exists or optional the timeout expires. ==...")
 
m (1 revision)
 
(3 intermediate revisions by one user not shown)
Line 26: Line 26:
  
 
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.
 
  
 
PID is the unique number which identifies a Process.
 
PID is the unique number which identifies a Process.
Line 40: Line 38:
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
ProcessClose("notepad.exe");
+
//waits until no instance of notepad.exe exists
 +
ProcessWaitClose("notepad.exe");
 +
 
 +
// This will wait until this particular instance of notepad has exited
 +
$PID = Run("notepad.exe");
 +
ProcessWaitClose($PID)
  
$PID = ProcessExists("notepad.exe"); // Will return the PID or 0 if the process isn't found.
 
If ($PID) ProcessClose($PID);
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Latest revision as of 12:38, 14 June 2015

ProcessWaitClose( <pid/name>, <timeout> )

Contents

Description

Pauses the current thread until a given process no longer exists or optional the timeout expires.

Parameters

pid/name

The name or PID of the process to check.

timeout

Optional; Specifies how long to wait (default is to wait indefinitely).

Return Value

Success: Returns 1.

Failure: Returns 0 if wait timed out.

Remarks

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

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

//waits until no instance of notepad.exe exists
ProcessWaitClose("notepad.exe");
 
// This will wait until this particular instance of notepad has exited
$PID = Run("notepad.exe");
ProcessWaitClose($PID)
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox