windows exec WMIC in try catch
This commit is contained in:
parent
fe9925ec99
commit
2ae03047ce
@ -100,6 +100,7 @@ Other changes
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 3.41.4 | 2018-05-28 | windows exec WMIC in try catch |
|
||||||
| 3.41.3 | 2018-05-13 | improved SunOS support `getStaticData()`, `getDynamicData()` |
|
| 3.41.3 | 2018-05-13 | improved SunOS support `getStaticData()`, `getDynamicData()` |
|
||||||
| 3.41.2 | 2018-05-13 | bugfix `system()` and `flags()` Raspberry Pi |
|
| 3.41.2 | 2018-05-13 | bugfix `system()` and `flags()` Raspberry Pi |
|
||||||
| 3.41.1 | 2018-05-11 | updated docs |
|
| 3.41.1 | 2018-05-11 | updated docs |
|
||||||
|
|||||||
@ -141,6 +141,7 @@ module.exports = function (callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining /value', opts, function (error, stdout) {
|
exec(util.getWmic() + ' Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining /value', opts, function (error, stdout) {
|
||||||
if (stdout) {
|
if (stdout) {
|
||||||
let lines = stdout.split('\r\n');
|
let lines = stdout.split('\r\n');
|
||||||
@ -158,6 +159,10 @@ module.exports = function (callback) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
19
lib/cpu.js
19
lib/cpu.js
@ -306,6 +306,7 @@ function getCpu() {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' cpu get name, description, revision, l2cachesize, l3cachesize, manufacturer, currentclockspeed, maxclockspeed /value', opts, function (error, stdout) {
|
exec(util.getWmic() + ' cpu get name, description, revision, l2cachesize, l3cachesize, manufacturer, currentclockspeed, maxclockspeed /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.split('\r\n');
|
let lines = stdout.split('\r\n');
|
||||||
@ -370,6 +371,9 @@ function getCpu() {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -546,6 +550,7 @@ function cpuTemperature(callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' /namespace:\\\\root\\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature', opts, function (error, stdout) {
|
exec(util.getWmic() + ' /namespace:\\\\root\\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
@ -563,6 +568,10 @@ function cpuTemperature(callback) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -579,6 +588,7 @@ function cpuFlags(callback) {
|
|||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
let result = '';
|
let result = '';
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec('reg query "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0" /v FeatureSet', opts, function (error, stdout) {
|
exec('reg query "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0" /v FeatureSet', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let flag_hex = stdout.split('0x').pop().trim();
|
let flag_hex = stdout.split('0x').pop().trim();
|
||||||
@ -602,6 +612,10 @@ function cpuFlags(callback) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (_linux) {
|
if (_linux) {
|
||||||
exec('lscpu', function (error, stdout) {
|
exec('lscpu', function (error, stdout) {
|
||||||
@ -764,6 +778,7 @@ function cpuCache(callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' cpu get l2cachesize, l3cachesize /value', opts, function (error, stdout) {
|
exec(util.getWmic() + ' cpu get l2cachesize, l3cachesize /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.split('\r\n');
|
let lines = stdout.split('\r\n');
|
||||||
@ -795,6 +810,10 @@ function cpuCache(callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -78,6 +78,7 @@ function fsSize(callback) {
|
|||||||
resolve(data);
|
resolve(data);
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' logicaldisk get Caption,FileSystem,FreeSpace,Size', opts, function (error, stdout) {
|
exec(util.getWmic() + ' logicaldisk get Caption,FileSystem,FreeSpace,Size', opts, function (error, stdout) {
|
||||||
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
||||||
lines.forEach(function (line) {
|
lines.forEach(function (line) {
|
||||||
@ -98,6 +99,10 @@ function fsSize(callback) {
|
|||||||
}
|
}
|
||||||
resolve(data);
|
resolve(data);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(data); }
|
||||||
|
resolve(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -167,7 +172,7 @@ function parseBlk(lines) {
|
|||||||
|
|
||||||
lines.filter(line => line !== '').forEach((line) => {
|
lines.filter(line => line !== '').forEach((line) => {
|
||||||
line = util.decodeEscapeSequence(line);
|
line = util.decodeEscapeSequence(line);
|
||||||
line = line.replace(/\\/g,'\\\\');
|
line = line.replace(/\\/g, '\\\\');
|
||||||
let disk = JSON.parse(line);
|
let disk = JSON.parse(line);
|
||||||
data.push({
|
data.push({
|
||||||
'name': disk.name,
|
'name': disk.name,
|
||||||
@ -258,6 +263,7 @@ function blockDevices(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
let drivetypes = ['Unknown', 'NoRoot', 'Removable', 'HDD', 'Network', 'CD/DVD', 'RAM'];
|
let drivetypes = ['Unknown', 'NoRoot', 'Removable', 'HDD', 'Network', 'CD/DVD', 'RAM'];
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /value', opts, function (error, stdout) {
|
exec(util.getWmic() + ' logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let devices = stdout.toString().split(/\n\s*\n/);
|
let devices = stdout.toString().split(/\n\s*\n/);
|
||||||
@ -288,6 +294,11 @@ function blockDevices(callback) {
|
|||||||
}
|
}
|
||||||
resolve(data);
|
resolve(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(data); }
|
||||||
|
resolve(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -735,8 +746,8 @@ function diskLayout(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' diskdrive get /value', {encoding: 'utf8', windowsHide: true}, function (error, stdout) {
|
exec(util.getWmic() + ' diskdrive get /value', { encoding: 'utf8', windowsHide: true }, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let devices = stdout.toString().split(/\n\s*\n/);
|
let devices = stdout.toString().split(/\n\s*\n/);
|
||||||
devices.forEach(function (device) {
|
devices.forEach(function (device) {
|
||||||
@ -767,6 +778,10 @@ function diskLayout(callback) {
|
|||||||
}
|
}
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -338,6 +338,7 @@ function graphics(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
// https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/
|
// https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' path win32_VideoController get AdapterCompatibility, AdapterDACType, name, PNPDeviceID, CurrentVerticalResolution, CurrentHorizontalResolution, CurrentNumberOfColors, AdapterRAM, CurrentBitsPerPixel, CurrentRefreshRate, MinRefreshRate, MaxRefreshRate, VideoMemoryType /value', opts, function (error, stdout) {
|
exec(util.getWmic() + ' path win32_VideoController get AdapterCompatibility, AdapterDACType, name, PNPDeviceID, CurrentVerticalResolution, CurrentHorizontalResolution, CurrentNumberOfColors, AdapterRAM, CurrentBitsPerPixel, CurrentRefreshRate, MinRefreshRate, MaxRefreshRate, VideoMemoryType /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let csections = stdout.split(/\n\s*\n/);
|
let csections = stdout.split(/\n\s*\n/);
|
||||||
@ -365,6 +366,10 @@ function graphics(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -157,8 +157,9 @@ function inetLatency(host, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
exec('ping ' + host + ' -n 1', opts, function (error, stdout) {
|
|
||||||
let result = -1;
|
let result = -1;
|
||||||
|
try {
|
||||||
|
exec('ping ' + host + ' -n 1', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\r\n');
|
let lines = stdout.toString().split('\r\n');
|
||||||
lines.shift();
|
lines.shift();
|
||||||
@ -174,6 +175,10 @@ function inetLatency(host, callback) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -199,6 +199,7 @@ function mem(callback) {
|
|||||||
if (_windows) {
|
if (_windows) {
|
||||||
let swaptotal = 0;
|
let swaptotal = 0;
|
||||||
let swapused = 0;
|
let swapused = 0;
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' pagefile get AllocatedBaseSize, CurrentUsage', opts, function (error, stdout) {
|
exec(util.getWmic() + ' pagefile get AllocatedBaseSize, CurrentUsage', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
||||||
@ -217,6 +218,10 @@ function mem(callback) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -228,7 +233,7 @@ function memLayout(callback) {
|
|||||||
|
|
||||||
function getManufacturer(manId) {
|
function getManufacturer(manId) {
|
||||||
if (OSX_RAM_manufacturers.hasOwnProperty(manId)) {
|
if (OSX_RAM_manufacturers.hasOwnProperty(manId)) {
|
||||||
return(OSX_RAM_manufacturers[manId]);
|
return (OSX_RAM_manufacturers[manId]);
|
||||||
}
|
}
|
||||||
return manId;
|
return manId;
|
||||||
}
|
}
|
||||||
@ -247,7 +252,7 @@ function memLayout(callback) {
|
|||||||
let lines = device.split('\n');
|
let lines = device.split('\n');
|
||||||
if (parseInt(util.getValue(lines, 'Size'), 10) > 0) {
|
if (parseInt(util.getValue(lines, 'Size'), 10) > 0) {
|
||||||
result.push({
|
result.push({
|
||||||
size: parseInt(util.getValue(lines, 'Size'), 10)*1024*1024,
|
size: parseInt(util.getValue(lines, 'Size'), 10) * 1024 * 1024,
|
||||||
bank: util.getValue(lines, 'Bank Locator'),
|
bank: util.getValue(lines, 'Bank Locator'),
|
||||||
type: util.getValue(lines, 'Type:'),
|
type: util.getValue(lines, 'Type:'),
|
||||||
clockSpeed: (util.getValue(lines, 'Configured Clock Speed:') ? parseInt(util.getValue(lines, 'Configured Clock Speed:'), 10) : (util.getValue(lines, 'Speed:') ? parseInt(util.getValue(lines, 'Speed:'), 10) : -1)),
|
clockSpeed: (util.getValue(lines, 'Configured Clock Speed:') ? parseInt(util.getValue(lines, 'Configured Clock Speed:'), 10) : (util.getValue(lines, 'Speed:') ? parseInt(util.getValue(lines, 'Speed:'), 10) : -1)),
|
||||||
@ -332,6 +337,7 @@ function memLayout(callback) {
|
|||||||
const memoryTypes = 'Unknown|Other|DRAM|Synchronous DRAM|Cache DRAM|EDO|EDRAM|VRAM|SRAM|RAM|ROM|FLASH|EEPROM|FEPROM|EPROM|CDRAM|3DRAM|SDRAM|SGRAM|RDRAM|DDR|DDR2|DDR2 FB-DIMM|Reserved|DDR3|FBD2|DDR4|LPDDR|LPDDR2|LPDDR3|LPDDR4'.split('|');
|
const memoryTypes = 'Unknown|Other|DRAM|Synchronous DRAM|Cache DRAM|EDO|EDRAM|VRAM|SRAM|RAM|ROM|FLASH|EEPROM|FEPROM|EPROM|CDRAM|3DRAM|SDRAM|SGRAM|RDRAM|DDR|DDR2|DDR2 FB-DIMM|Reserved|DDR3|FBD2|DDR4|LPDDR|LPDDR2|LPDDR3|LPDDR4'.split('|');
|
||||||
const FormFactors = 'Unknown|Other|SIP|DIP|ZIP|SOJ|Proprietary|SIMM|DIMM|TSOP|PGA|RIMM|SODIMM|SRIMM|SMD|SSMP|QFP|TQFP|SOIC|LCC|PLCC|BGA|FPBGA|LGA'.split('|');
|
const FormFactors = 'Unknown|Other|SIP|DIP|ZIP|SOJ|Proprietary|SIMM|DIMM|TSOP|PGA|RIMM|SODIMM|SRIMM|SMD|SSMP|QFP|TQFP|SOIC|LCC|PLCC|BGA|FPBGA|LGA'.split('|');
|
||||||
|
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' memorychip get BankLabel, Capacity, ConfiguredClockSpeed, ConfiguredVoltage, MaxVoltage, MinVoltage, DataWidth, FormFactor, Manufacturer, MemoryType, PartNumber, SerialNumber, Speed, Tag /value', opts, function (error, stdout) {
|
exec(util.getWmic() + ' memorychip get BankLabel, Capacity, ConfiguredClockSpeed, ConfiguredVoltage, MaxVoltage, MinVoltage, DataWidth, FormFactor, Manufacturer, MemoryType, PartNumber, SerialNumber, Speed, Tag /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let devices = stdout.toString().split('BankL');
|
let devices = stdout.toString().split('BankL');
|
||||||
@ -356,6 +362,10 @@ function memLayout(callback) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -366,6 +366,7 @@ function networkStats(iface, callback) {
|
|||||||
let perfData = [];
|
let perfData = [];
|
||||||
let nics = [];
|
let nics = [];
|
||||||
cmd = util.getWmic() + ' nic get MACAddress, name, NetEnabled /value';
|
cmd = util.getWmic() + ' nic get MACAddress, name, NetEnabled /value';
|
||||||
|
try {
|
||||||
exec(cmd, opts, function (error, stdout) {
|
exec(cmd, opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const nsections = stdout.split(/\n\s*\n/);
|
const nsections = stdout.split(/\n\s*\n/);
|
||||||
@ -417,6 +418,10 @@ function networkStats(iface, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.rx = _network[iface].rx;
|
result.rx = _network[iface].rx;
|
||||||
@ -582,6 +587,7 @@ function networkConnections(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
let cmd = 'netstat -na';
|
let cmd = 'netstat -na';
|
||||||
|
try {
|
||||||
exec(cmd, opts, function (error, stdout) {
|
exec(cmd, opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
|
||||||
@ -635,6 +641,10 @@ function networkConnections(callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -244,6 +244,7 @@ function osInfo(callback) {
|
|||||||
if (_windows) {
|
if (_windows) {
|
||||||
result.logofile = getLogoFile();
|
result.logofile = getLogoFile();
|
||||||
result.release = result.kernel;
|
result.release = result.kernel;
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' os get Caption', opts, function (error, stdout) {
|
exec(util.getWmic() + ' os get Caption', opts, function (error, stdout) {
|
||||||
result.distro = result.codename = stdout.slice(stdout.indexOf('\r\n') + 2).trim();
|
result.distro = result.codename = stdout.slice(stdout.indexOf('\r\n') + 2).trim();
|
||||||
if (callback) {
|
if (callback) {
|
||||||
@ -251,6 +252,10 @@ function osInfo(callback) {
|
|||||||
}
|
}
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -292,6 +297,7 @@ function versions(callback) {
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
try {
|
||||||
exec('npm -v', function (error, stdout) {
|
exec('npm -v', function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
result.npm = stdout.toString().split('\n')[0];
|
result.npm = stdout.toString().split('\n')[0];
|
||||||
@ -381,6 +387,10 @@ function versions(callback) {
|
|||||||
}
|
}
|
||||||
functionProcessed();
|
functionProcessed();
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,6 +140,7 @@ function services(srv, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' service get /value', { maxBuffer: 1024 * 1000, windowsHide: true }, function (error, stdout) {
|
exec(util.getWmic() + ' service get /value', { maxBuffer: 1024 * 1000, windowsHide: true }, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let serviceSections = stdout.split(/\n\s*\n/);
|
let serviceSections = stdout.split(/\n\s*\n/);
|
||||||
@ -186,6 +187,10 @@ function services(srv, callback) {
|
|||||||
resolve(data);
|
resolve(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(data); }
|
||||||
|
resolve(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (callback) { callback({}); }
|
if (callback) { callback({}); }
|
||||||
@ -582,6 +587,7 @@ function processes(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' process get /value', { maxBuffer: 1024 * 1000, windowsHide: true }, function (error, stdout) {
|
exec(util.getWmic() + ' process get /value', { maxBuffer: 1024 * 1000, windowsHide: true }, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let processSections = stdout.split(/\n\s*\n/);
|
let processSections = stdout.split(/\n\s*\n/);
|
||||||
@ -666,6 +672,10 @@ function processes(callback) {
|
|||||||
}
|
}
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (callback) { callback(_process_cpu.result); }
|
if (callback) { callback(_process_cpu.result); }
|
||||||
|
|||||||
@ -188,6 +188,7 @@ function system(callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' csproduct get /value', opts, function (error, stdout) {
|
exec(util.getWmic() + ' csproduct get /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
// let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0)[0].trim().split(/\s\s+/);
|
// let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0)[0].trim().split(/\s\s+/);
|
||||||
@ -209,6 +210,10 @@ function system(callback) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -261,6 +266,7 @@ function bios(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
// TODO: check BIOS windows
|
// TODO: check BIOS windows
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' bios get /value', opts, function (error, stdout) {
|
exec(util.getWmic() + ' bios get /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\r\n');
|
let lines = stdout.toString().split('\r\n');
|
||||||
@ -287,6 +293,10 @@ function bios(callback) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -350,6 +360,7 @@ function baseboard(callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec(util.getWmic() + ' baseboard get /value', opts, function (error, stdout) {
|
exec(util.getWmic() + ' baseboard get /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\r\n');
|
let lines = stdout.toString().split('\r\n');
|
||||||
@ -370,6 +381,10 @@ function baseboard(callback) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -245,6 +245,7 @@ function users(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
try {
|
||||||
exec('query user', opts, function (error, stdout) {
|
exec('query user', opts, function (error, stdout) {
|
||||||
if (stdout) {
|
if (stdout) {
|
||||||
// lines / split
|
// lines / split
|
||||||
@ -254,6 +255,10 @@ function users(callback) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user