"tasklist" is a DOS command that displays the running processes in the Windows OS.It displays all the applications and services running with their PID(process ID).
Syntax
tasklist[.exe] [/s computer] [/u domain\user [/p password]] [/fo {TABLE|LIST|CSV}] [/nh] [/fi FilterName [/fi FilterName2 [ ... ]]] [/m [ModuleName] | /svc | /v]
Parameters | Uses |
---|---|
/S system | Specifies the remote system to connect to. |
/U [domain\]user | Specifies the user context under which the command should execute. |
/P [password] | Specifies the password for the given user context. Prompts for input if omitted. |
/M [module] | Lists all tasks currently using the given exe/dll name. If the module name is not specified all loaded modules are displayed. |
/SVC | Displays services hosted in each process. |
/V | Displays verbose task information. |
/FI filter | Displays a set of tasks that match a given criteria specified by the filter. |
/FO format | Specifies the output format. Valid values: "TABLE", "LIST", "CSV". |
/NH | Specifies that the "Column Header" should not be displayed in the output. Valid only for "TABLE" and "CSV" formats. |
Filters
Filter Name | Valid Operators | Valid values |
---|---|---|
STATUS | eq, ne | RUNNING | NOT RESPONDING | UNKNOWN |
IMAGENAME | eq, ne | Image name |
PID | eq, ne, gt, lt, ge, le | PID value |
SESSION | eq, ne, gt, lt, ge, le | Session number |
SESSIONNAME | eq, ne | Session name |
CPUTIME | eq, ne, gt, lt, ge, le | CPU time in the format of hh:mm:ss.hh - hours,mm - minutesss - seconds |
MEMUSAGE | eq, ne, gt, lt, ge, le | Memory usage in KB |
USERNAME | eq, ne | User name in [domain\]user format |
SERVICES | eq, ne | Service name |
WINDOWTITLE | eq, ne | Window title |
MODULES | eq, ne | DLL name |
Now let us see how we can make utilization of this command with the help of some examples:-
- tasklist /s Computer
Process info of local/remote System |
- tasklist -v
- tasklist -fi
- tasklist -v -fi "ImageName eq VLC.exe" /fo csv
To get VLC Windows Title |
public String CallMe()
{
Runtime runtime = Runtime.getRuntime();
String cmds[] = {"cmd", "/c", "tasklist","/v","/fi","ImageName eq VLC.exe","/fo","CSV"};
Process proc;
String val = null;
try {
proc = runtime.exec(cmds);
InputStream inputstream = proc.getInputStream();
InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
String line;
int count = 0;
while ((line = bufferedreader.readLine()) != null) {
if(count==1)
{
String[] a = line.split(",");
val = a[9];
}
count++;
}
} catch (IOException e) {
e.printStackTrace();
}
return val;
}
|
This can be used to set curent soundtrack as your GTalk status by using SMACK api to communicate with GOOGLE.
This will be explained in more depth in my next Blog.
No comments:
Post a Comment