How to use the wmic.run function in wmic

To help you get started, we’ve selected a few wmic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prey / prey-node-client / lib / agent / providers / processes / windows.js View on Github external
exports.get_process_list = function(callback) {
  var query = 'path Win32_Process where "UserModeTime != 0" get Caption,ParentProcessId,ProcessId,UserModeTime';

  wmic.run(query, function(err, out, wmic_pid) {
    if (err) return callback(err);

    callback(null, out.split(/\n/)
     .filter(function(line) {
       // TODO: probably locale fubar on System Idle Process
       return line.length > 1 && line.indexOf("System Idle Process") === -1;
    })
     .splice(1)
     .map(function(line) {

       var fields = line.split(/\s+/),
           pid    = parseInt(fields[2]);

       if (pid === wmic_pid) return null;

       return  {
github prey / prey-node-client / lib / agent / providers / network / windows.js View on Github external
exports.get_wireless_interfaces_list = function(callback) {
  var query = 'nic where "Name like \'%Wireless%\'" get NetConnectionID';
  wmic.run(query, function(err, o) {
    if (err) return callback(err);

    var list = o.split("\n").splice(1).map(function(n) { return n.trim(); });
    callback(null, list);
  });
};
github prey / prey-node-client / lib / agent / providers / indicators / windows.js View on Github external
exports.get_remaining_storage = function(cb) {
  var cmd ="Logicaldisk where name='C:' get Size,Freespace";

  wmic.run(cmd, function(err, stdout){
    if (err) return cb(err);

    var cols = stdout.split("\n")[1].trim().split(/\s+/);

    var info = {
      total_gb: cols[0],
      free_gb : cols[1],
      used    : (cols[0]/cols[1])*100
    };

    cb(null, info);
  });
};

wmic

Wrapper around the WMIC Windows command interface.

MIT
Latest version published 3 years ago

Package Health Score

47 / 100
Full package analysis