mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 07:43:50 +00:00
Worked around wmic formatting bug in Windows 7 / Server 2008
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -147,32 +147,34 @@ function windows_identifiers()
|
|||||||
ret['identifiers']['product_uuid'] = values['UUID'];
|
ret['identifiers']['product_uuid'] = values['UUID'];
|
||||||
trimIdentifiers(ret.identifiers);
|
trimIdentifiers(ret.identifiers);
|
||||||
|
|
||||||
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'MEMORYCHIP', 'LIST', '/FORMAT:CSV']);
|
var CSV = '/FORMAT:"' + require('util-language').wmicXslPath + 'csv"';
|
||||||
|
|
||||||
|
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'MEMORYCHIP', 'LIST', CSV]);
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
ret.windows.memory = windows_wmic_results(child.stdout.str);
|
ret.windows.memory = windows_wmic_results(child.stdout.str);
|
||||||
|
|
||||||
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'OS', 'GET', '/FORMAT:CSV']);
|
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'OS', 'GET', CSV]);
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
ret.windows.osinfo = windows_wmic_results(child.stdout.str)[0];
|
ret.windows.osinfo = windows_wmic_results(child.stdout.str)[0];
|
||||||
|
|
||||||
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'PARTITION', 'LIST', '/FORMAT:CSV']);
|
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'PARTITION', 'LIST', CSV]);
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
ret.windows.partitions = windows_wmic_results(child.stdout.str);
|
ret.windows.partitions = windows_wmic_results(child.stdout.str);
|
||||||
|
|
||||||
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'CPU', 'LIST', 'BRIEF', '/FORMAT:CSV']);
|
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'CPU', 'LIST', 'BRIEF', CSV]);
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
ret.windows.cpu = windows_wmic_results(child.stdout.str);
|
ret.windows.cpu = windows_wmic_results(child.stdout.str);
|
||||||
|
|
||||||
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'PATH', 'Win32_VideoController', 'GET', 'Name,CurrentHorizontalResolution,CurrentVerticalResolution', '/FORMAT:CSV']);
|
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'PATH', 'Win32_VideoController', 'GET', 'Name,CurrentHorizontalResolution,CurrentVerticalResolution', CSV]);
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
ret.windows.gpu = windows_wmic_results(child.stdout.str);
|
ret.windows.gpu = windows_wmic_results(child.stdout.str);
|
||||||
|
|
||||||
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'diskdrive', 'LIST', 'BRIEF', '/FORMAT:CSV']);
|
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'diskdrive', 'LIST', 'BRIEF', CSV]);
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
ret.windows.drives = windows_wmic_results(child.stdout.str);
|
ret.windows.drives = windows_wmic_results(child.stdout.str);
|
||||||
@@ -261,7 +263,8 @@ function win_chassisType()
|
|||||||
|
|
||||||
function win_systemType()
|
function win_systemType()
|
||||||
{
|
{
|
||||||
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'ComputerSystem', 'get', 'PCSystemType', '/FORMAT:CSV']);
|
var CSV = '/FORMAT:"' + require('util-language').wmicXslPath + 'csv"';
|
||||||
|
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'ComputerSystem', 'get', 'PCSystemType', CSV]);
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
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.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
|
|||||||
@@ -1036,3 +1036,38 @@ Object.defineProperty(obj, 'current', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
module.exports = obj;
|
module.exports = obj;
|
||||||
|
|
||||||
|
if (process.platform == 'win32')
|
||||||
|
{
|
||||||
|
Object.defineProperty(module.exports, 'wmicXslPath',
|
||||||
|
{
|
||||||
|
get: function ()
|
||||||
|
{
|
||||||
|
if (this._wmicpath == null)
|
||||||
|
{
|
||||||
|
var tmp = process.env['windir'] + '\\system32\\wbem\\' + this.current + '\\';
|
||||||
|
if (require('fs').existsSync(tmp + 'csv.xsl'))
|
||||||
|
{
|
||||||
|
this._wmicpath = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(this._wmicpath == null)
|
||||||
|
{
|
||||||
|
var f = require('fs').readdirSync(process.env['windir'] + '\\system32\\wbem');
|
||||||
|
for(var i in f)
|
||||||
|
{
|
||||||
|
var path = process.env['windir'] + '\\system32\\wbem\\' + f[i];
|
||||||
|
if(require('fs').statSync(path).isDirectory())
|
||||||
|
{
|
||||||
|
if (require('fs').existsSync(path + '\\csv.xsl'))
|
||||||
|
{
|
||||||
|
this._wmicpath = path + '\\';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (this._wmicpath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user