Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 {
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);
});
};
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);
});
};