JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q49777F

A Node .js wrapper for Microsoft Windows' tasklist and taskkill

Package Exports

  • ms-task

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ms-task) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

MS-Task

Description

MS-Task is a Node.js wrapper for Microsoft Windows' tasklist and taskkill. Tasklist "displays a list of applications and services with their Process ID (PID) for all tasks running on either a local or a remote computer." Taskkill "ends one or more tasks or processes." Supported versions: Windows XP, Vista, 7, and 8.

Installation

You may install MS-Task via Node Package Manager as follows:

npm install ms-task 

The source code is available on GitHub.

Commands

Process names passed to MS-Task are not case-sensitive, but must contain the file extension (e.g. "exe"). All task finding functions will fail if tasklist.exe is not located in C:\Windows\System32, and task.kill will fail if taskkill.exe is not located in C:\Windows\System32.

var task = require('ms-task'); 

task(arg, callback(err, data) function{}); 

Call tasklist.exe with the supplied arguments. Valid arguments are documented here. Be sure to use nested or escaped quotes when necessary in the argument. The callback will contain err and data variables. Data is table, list, or CSV string of information about a matched process or processes, depending on the arguments supplied. Choosing CSV and using node-csv is an easy way to deal with the resulting data.

task.list(arg, callback(err, data) function{}); 

This convenience method is equivalent to task(arg, callback(err, data) function{});

task.procStat(proc, callback(err, data, amount) function{}); 

Search for a given process name or PID (proc). Err is null if a process was found. Data is an object which contains information (process name, PID, session name, session number, and memory usage) about a matched process or processes. It has two properties, array (an array of arrays) and object (an array of objects), which are essentially two different ways of accessing the same data. The properties of data.object are name, pid, sessionName, sessionNumber, and memUsage. For example, to find the memory usage of the first process found, you could use data.array[0][4] or data.object[0].memUsage. Amount is an integer representation of the amount of processes found; it is provided for convenience and is equivalent to data.array.length.

task.pidOf(procName, callback(err, data, amount) function{}); 

Search for one or more PIDs that match a give process name (procName). Err is null if a PID was found. Data is an array of matched PIDs. For example, the PID of the first process found would be data[0]. Amount is an integer representation of the amount of processes found; it is provided for convenience and is equivalent to data.array.length.

task.nameOf(PID, callback(err, data) function{}); 

Search for the process name that corresponds with the supplied PID. Err is null if a process name was found. Data is the matching process name.

task.kill(proc, [callback(err) function{}]); 

Kill a given process name or PID (proc). Callback is optional, and err is null if a process name or PID was killed successfully. If a process name is passed for proc, and multiple matches are found, all of the matches are killed.

Examples

See test/test.js. Before running the test, be sure to:

cd test/ 
npm install 

This will download the async module, which is required for the test, but not MS-Task itself.

Improving MS-Task

If you would like to contribute code, feel free to submit a pull request. Please report issues here.