replace av and chassistype with wmi instead of powershell

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
si458
2025-11-16 16:18:40 +00:00
parent da73bff99e
commit 9545bec218
3 changed files with 477 additions and 54 deletions

View File

@@ -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
}