npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ms-wmic

v1.0.4

Published

A Node.js wrapper for Microsoft Windows' WMIC

Downloads

26

Readme

node-ms-wmic

A Node.js wrapper for Microsoft Windows' WMIC

Installation

npm i ms-wmic

API

Note: All API methods return the wmic object for chaining.

wmic.execute(args, cb)

Execute WMIC with the provided args

  • string args - WMIC CLI arguments
  • function(null | object err, string stdOut) cb - A function to be called after WMIC is executed

Example

wmic.execute('process where name="notepad.exe" get executablepath', function (err, stdOut) {
    if (err) {
        console.error(err);
    }
    
    console.log(stdOut);
});

wmic.process.get(opt, cb)

Retrieve specific process properties given one or more optional search conditions

  • object opt - An options object
    • object{string | number} | object{object{string | number}} where - (Optional) An object in which a key is
      1. operator, with a value of "AND" or "OR" (case-insensitive). Will determine how search conditions are joined. If omitted, conditions are joined with "AND".
      2. A process property, with a value of either a process property value to match with an equal to comparison or an object containing operator and value keys. operator is a WQL operator or LIKE Operator. value is a process property value.
    • array{string} get - Process properties to get
  • function(null | object err, array{object{string}} processes) cb - A callback to executed after the process properties are retrieved.

Examples

// Get a specific property of all processes
wmic.process.get({get: ['processId']}, function(err, processes, stdOut) {
    if (err) {
        console.error(err);
    }

    console.log(processes);
    console.log(stdOut);
});

// Simple equal to where comparison
wmic.process.get({
    where: {name: 'spotify.exe'},
    get: ['name', 'executablePath', 'threadCount']
}, function(err, processes, stdOut) {
    if (err) {
        console.error(err);
    }
    
    console.log(processes);
    console.log(stdOut);
});

// Advanced comparison via operators
wmic.process.get({
    where: {
        operator: 'OR',
        writeOperationCount: {
            operator: '>',
            value: 10
        },
        executablePath: {
            operator: 'LIKE',
            value: '%C:\\\\Program Files (x86)%chrome.exe%'
        }
    },
    get: ['workingSetSize', 'processId']
}, function(err, processes, stdOut) {
    if (err) {
        console.error(err);
    }
    
    console.log(processes);
    console.log(stdOut);
});

wmic.process.list(where, cb)

Retrieve all available process properties given one or more optional search conditions

  • object{string | number} | object{object{string | number}} where - (Optional) An object in which a key is
    1. operator, with a value of "AND" or "OR" (case-insensitive). Will determine how search conditions are joined. If omitted, conditions are joined with "AND".
    2. A process property, with a value of either a process property value to match with an equal to comparison or an object containing operator and value keys. operator is a WQL operator or LIKE Operator. value is a process property value.
  • function(null | object err, array{object{string}} processes) cb - A callback to executed after the process properties are retrieved.

Examples

// Get properties of all processes
wmic.process.list(function(err, processes, stdOut) {
    if (err) {
        console.error(err);
    }

    console.log(processes);
    console.log(stdOut);
});

// Simple equal to where comparison
wmic.process.list({CSName: 'SOME-MACHINE'}, function(err, processes, stdOut) {
    if (err) {
        console.error(err);
    }
    
    console.log(processes);
    console.log(stdOut);
});

// Advanced comparison via operators
wmic.process.list({
    operator: 'OR',
    threadCount: {
        operator: '>',
        value: 1
    },
    name: {
        operator: 'LIKE',
        value: 'firef[i-p]x.exe'
    }
}, function(err, processes, stdOut) {
    if (err) {
        console.error(err);
    }

    console.log(processes);
    console.log(stdOut);
});

wmic.process.call(opt, cb)

Execute a method on process(es) given one or more search conditions

  • object opt - An options object
    • object{string | number} | object{object{string | number}} where - An object in which a key is
      1. operator, with a value of "AND" or "OR" (case-insensitive). Will determine how search conditions are joined. If omitted, conditions are joined with "AND".
      2. A process property, with a value of either a process property value to match with an equal to comparison or an object containing operator and value keys. operator is a WQL operator or LIKE Operator. value is a process property value.
    • string call - The method to execute
  • function(null | object err, array{object{string}} stdOut) cb - A callback to be executed after the method is called.

Examples

// Simple equal to where comparison
wmic.process.call({
    where: { name: 'taskmgr.exe' },
    call: 'terminate'
}, function(err, stdOut) {
    if (err) {
        console.error(err);
    }

    console.log(stdOut);
});

// Advanced comparison via operators
wmic.process.call({
    where: {
        operator: 'OR',
        name: {
            operator: 'LIKE',
            value: '%ccleaner%'
        }
    },
    call: 'getowner'
}, function(err, stdOut) {
    if (err) {
        console.error(err);
    }

    console.log(stdOut);
});

wmic.process.terminate(opt, cb)

Terminate process(es) given one or more search conditions

  • object opt - An options object
    • object{string | number} | object{object{string | number}} where - An object in which a key is
      1. operator, with a value of "AND" or "OR" (case-insensitive). Will determine how search conditions are joined. If omitted, conditions are joined with "AND".
      2. A process property, with a value of either a process property value to match with an equal to comparison or an object containing operator and value keys. operator is a WQL operator or LIKE Operator. value is a process property value.
  • function(null | object err, array{object{string}} stdOut) cb - A callback to be executed after the process(es) are terminated.

Examples

// Simple equal to where comparison
wmic.process.call({
    where: { name: 'taskmgr.exe' },
    call: 'terminate'
}, function(err, stdOut) {
    if (err) {
        console.error(err);
    }

    console.log(stdOut);
});

// Advanced comparison via operators
wmic.process.call({
    where: {
        operator: 'OR',
        name: {
            operator: 'LIKE',
            value: '%ccleaner%'
        }
    },
    call: 'getowner'
}, function(err, stdOut) {
    if (err) {
        console.error(err);
    }

    console.log(stdOut);
});