Core Function ProcessList

From Sputnik Wiki
Jump to: navigation, search
ProcessList( <name> )

Contents

Description

Returns an array listing the currently running processes (names and PIDs)

Parameters

name

Optional; If a name is given only processes of the same name will be returned.

Return Value

Success: An array of process names and PIDs (See Example). Failure: An empty array.

Remarks

None.

Example

Print all process names and pids :

foreach ( ProcessList() as $pList )
{
	println("Name '$pList[0]' PID '$pList[1]'");
}

Print just the notepad process name and pid :

foreach ( ProcessList("Notepad.exe") as $pList )
{
	println("Name '$pList[0]' PID '$pList[1]'");
}

A simple function to accept a process name and return its pid or return -1 :

println( "Notepad PID : " . FindPID("Notepad.exe") );
 
Function FindPID( $Name )
{
	foreach ( ProcessList($Name) as $pList )
		return $pList[1];
	return -1;
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox