public class WinProcess extends Object
On Windows, there are several system pseudo-processes, for which many of the getter invocations would fail. This includes "system idle process" (which always seem to have PID=0) and "System" (which always seem to have PID=4)
Constructor and Description |
---|
WinProcess(int pid)
Wraps a process ID.
|
WinProcess(Process proc)
Wraps
Process into WinProcess . |
Modifier and Type | Method and Description |
---|---|
static Iterable<WinProcess> |
all()
Enumerates all the processes in the system.
|
static void |
enableDebugPrivilege()
Elevates the security privilege of this process
so that we can obtain information about processes
owned by other users.
|
String |
getCommandLine()
Gets the command line given to this process.
|
TreeMap<String,String> |
getEnvironmentVariables()
Gets the environment variables of this process.
|
int |
getPid()
Gets the process ID.
|
boolean |
isCriticalProcess() |
boolean |
isRunning() |
void |
kill() |
void |
killRecursively()
Kills this process and all the descendant processes that
this process launched.
|
boolean |
sendCtrlC()
Sends Ctrl+C to the process.
|
void |
setPriority(int priority)
Sets the execution priority of this thread.
|
String |
toString() |
public WinProcess(int pid)
public WinProcess(Process proc)
Process
into WinProcess
.public int getPid()
public void killRecursively()
public void kill()
@CheckReturnValue public boolean sendCtrlC() throws WinpException
true
if the signal was delivered successfullyWinpException
- Execution errorpublic boolean isRunning()
public boolean isCriticalProcess()
public void setPriority(int priority)
priority
- One of the values from Priority
.public String getCommandLine()
WinpException
- If Winp fails to obtain the command line.
The process may be dead or there is not enough security privileges.public TreeMap<String,String> getEnvironmentVariables()
The returned map has a case-insensitive comparison semantics.
WinpException
- If Winp fails to obtain the environment variables.
The process may be dead or there is not enough security privileges.public static Iterable<WinProcess> all()
WinpException
- If the enumeration fails.public static void enableDebugPrivilege()
Otherwise some of the getter methods may fail
with WinpException
due to access denied error.
Copyright © 2018. All rights reserved.