mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-21 02:09:05 -05:00
replace av and chassistype with wmi instead of powershell
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
@@ -702,17 +702,12 @@ function hexToAscii(hexString) {
|
||||
|
||||
function win_chassisType()
|
||||
{
|
||||
// needs to be replaced with win-wmi but due to bug in win-wmi it doesnt handle arrays correctly
|
||||
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], {});
|
||||
if (child == null) { return ([]); }
|
||||
child.descriptorMetadata = 'process-manager';
|
||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
||||
child.stdin.write('Get-WmiObject Win32_SystemEnclosure | Select-Object -ExpandProperty ChassisTypes\r\n');
|
||||
child.stdin.write('exit\r\n');
|
||||
child.waitExit();
|
||||
// use new win-wmi-fixed module to get arrays correctly for time being
|
||||
try {
|
||||
return (parseInt(child.stdout.str));
|
||||
var tokens = require('win-wmi-fixed').query('ROOT\\CIMV2', 'SELECT ChassisTypes FROM Win32_SystemEnclosure', ['ChassisTypes']);
|
||||
if (tokens[0]) {
|
||||
return (parseInt(tokens[0]['ChassisTypes'][0]));
|
||||
}
|
||||
} catch (e) {
|
||||
return (2); // unknown
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user