JSPM

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

Dependency-free promise based wrapper for the Windows tasklist command. Non-English locale friendly as much as possible.

Package Exports

  • win-tasklist

Readme

Dependency-free promise based wrapper for the Windows tasklist command.

Note about locale:

Most Windows commands change their output based on system's locale, which can be sometimes difficult when you are trying to parse the output of a non-English system. This module tries to be system-locale-independent as much as possible in order to be able to parse the tasklist output. Unfortunately user and windowTitle returned properties will remain locale-dependent (Not sure about sessionType ?).

Install & Usage example

$ npm install win-tasklist

Get a specific process information :

const tasklist = require('win-tasklist');

tasklist.getProcessInfo("explorer.exe",{verbose: true}).then((process)=>{

  console.log(process);
  
  /* OUTPUT
  [ { process: 'explorer.exe',
      pid: 6960,
      sessionType: 'console',
      sessionNumber: 1,
      memUsage: 169783296,
      state: 'running',
      user: 'skynet\\xan',
      cpuTime: '0:02:15',
      windowTitle: 'n/a' } ]  
  */


}).catch((err)=>{
  console.error(err);
});

List them all :

const tasklist = require('win-tasklist');

tasklist().then((list)=>{

  console.log(list);
  
  /* OUTPUT
  [ { process: 'system idle process',
      pid: 0,
      sessionType: 'services',
      sessionNumber: 0,
      memUsage: 8192 },
    { process: 'system',
      pid: 4,
      sessionType: 'services',
      sessionNumber: 0,
      memUsage: 2580480 }, 
      ... 100 more items ]
  */


}).catch((err)=>{
  console.error(err);
});

API

It's always good to have a look at the official tasklist doc.

tasklist([option])

Promise.
Returns an [Array] of object or null

options

  • verbose (default: false)
    if false will return the following properties : process, pid, sessionType, sessionNumber, memUsage (bytes).
    if true will additionally return the following properties : state, user, cpuTime, windowTitle.

    Keep in mind using the verbose option might impact performance.

  • remote (default: null)
    Name or IP address of a remote computer.
    Must be used with user and password options below.

  • user (default: null)
    Username or Domain\Username.

  • password (default: null)
    User's password.

  • uwpOnly (default: false)
    List only Windows Store Apps (UWP).
    NB: With this option to true and verbose to false; tasklist only returns process, pid, memUsage (bytes) and AUMID.

  • filter (default: [])

    Array of string. Each string being a filter.

    eg filter for listing only running processes :

    ["STATUS eq RUNNING"]

    From the tasklist doc :

    Filter Name Valid Operators Valid Values
    STATUS eq, ne RUNNING
    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 HH:MM:SS, where MM and SS are between 0 and 59 and HH is any unsigned number
    MEMUSAGE eq, ne, gt, lt, ge, le Memory usage in KB
    USERNAME eq, ne Any valid user name
    SERVICES eq, ne Service name
    WINDOWTITLE eq, ne Window title
    MODULES eq, ne DLL name

Helper function:

  • getProcessInfo(process,[option])

    Promise.

    process can either be a PID or an imagename.
    Same option as main function minus filter.

    Returns an [Array] of object or null

  • isProcessRunning(process,[option])

    Promise.

    process can either be a PID or an imagename.
    Same options as main function minus filter and verbose.

    Return true if the specified process is running (meaning it has the status RUNNING),
    false otherwise.

    Equivalent of filter IMAGENAME/PID eq %process% and STATUS eq RUNNING.

  • hasProcess(process,[option])

    Promise.

    process can either be a PID or an imagename.
    Same options as main function minus filter and verbose.

    Return true if the specified process is loaded (meaning it is listed in the tasklist),
    false otherwise.

    Equivalent of filter IMAGENAME/PID eq %process%.