public class WindowsProcessManager extends AbstractProcessManager
ProcessManager
implementation for Windows.
Requires wmic.exe and taskkill.exe, that should be available at least on Windows XP, Windows Vista, and Windows 7 (except Home versions).
PID_NOT_FOUND, PID_UNKNOWN
Constructor and Description |
---|
WindowsProcessManager() |
Modifier and Type | Method and Description |
---|---|
static WindowsProcessManager |
getDefault()
Gets the default instance of
WindowsProcessManager . |
protected java.lang.String[] |
getRunningProcessesCommand(java.lang.String process)
Gets the command to be executed to get a snapshot of all the running processes identified by
the specified argument (process).
|
protected java.util.regex.Pattern |
getRunningProcessLinePattern()
Gets the pattern to be used to match an output line containing the information about a running
process.
|
boolean |
isUsable()
Gets whether the commands we need are available for a Windows OS.
|
void |
kill(java.lang.Process process,
long pid)
Kills the specified process.
|
execute, findPid
public static WindowsProcessManager getDefault()
WindowsProcessManager
.WindowsProcessManager
instance.protected java.lang.String[] getRunningProcessesCommand(java.lang.String process)
AbstractProcessManager
getRunningProcessesCommand
in class AbstractProcessManager
process
- The name of the process to query for.protected java.util.regex.Pattern getRunningProcessLinePattern()
AbstractProcessManager
getRunningProcessLinePattern
in class AbstractProcessManager
AbstractProcessManager.getRunningProcessesCommand(String)
public boolean isUsable()
true
If the required commands are available, false
otherwise.public void kill(java.lang.Process process, long pid) throws java.io.IOException
ProcessManager
process
- The process to kill.pid
- The id of the process to kill.java.io.IOException
- If an IO error occurs.