systeminformation 5.9.4 → 5.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/graphics.js CHANGED
@@ -13,7 +13,6 @@
13
13
  // 7. Graphics (controller, display)
14
14
  // ----------------------------------------------------------------------------------
15
15
 
16
- const os = require('os');
17
16
  const fs = require('fs');
18
17
  const exec = require('child_process').exec;
19
18
  const execSync = require('child_process').execSync;
@@ -769,9 +768,9 @@ function graphics(callback) {
769
768
  // https://devblogs.microsoft.com/scripting/use-powershell-to-discover-multi-monitor-information/
770
769
  try {
771
770
  const workload = [];
772
- workload.push(util.wmic('path win32_VideoController get /value'));
771
+ workload.push(util.powerShell('Get-WmiObject win32_VideoController | fl *'));
773
772
  workload.push(util.powerShell('gp "HKLM:\\SYSTEM\\ControlSet001\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\*" -ErrorAction SilentlyContinue | where MatchingDeviceId $null -NE | select MatchingDeviceId,HardwareInformation.qwMemorySize | fl'));
774
- workload.push(util.wmic('path win32_desktopmonitor get /value'));
773
+ workload.push(util.powerShell('Get-WmiObject win32_desktopmonitor | fl *'));
775
774
  workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorBasicDisplayParams | fl'));
776
775
  workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens'));
777
776
  workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorConnectionParams | fl'));
@@ -783,13 +782,13 @@ function graphics(callback) {
783
782
  workload
784
783
  ).then(data => {
785
784
  // controller + vram
786
- let csections = data[0].split(/\n\s*\n/);
787
- let vsections = data[1].split(/\n\s*\n/);
785
+ let csections = data[0].replace(/\r/g, '').split(/\n\s*\n/);
786
+ let vsections = data[1].replace(/\r/g, '').split(/\n\s*\n/);
788
787
  result.controllers = parseLinesWindowsControllers(csections, vsections);
789
788
  result.controllers = result.controllers.map((controller) => { // match by subDeviceId
790
789
  if (controller.vendor.toLowerCase() === 'nvidia') {
791
790
  return mergeControllerNvidia(controller, nvidiaData.find(device => {
792
- let windowsSubDeviceId = controller.subDeviceId.toLowerCase();
791
+ let windowsSubDeviceId = (controller.subDeviceId || '').toLowerCase();
793
792
  const nvidiaSubDeviceIdParts = device.subDeviceId.split('x');
794
793
  let nvidiaSubDeviceId = nvidiaSubDeviceIdParts.length > 1 ? nvidiaSubDeviceIdParts[1].toLowerCase() : nvidiaSubDeviceIdParts[0].toLowerCase();
795
794
  const lengthDifference = Math.abs(windowsSubDeviceId.length - nvidiaSubDeviceId.length);
@@ -810,25 +809,25 @@ function graphics(callback) {
810
809
  });
811
810
 
812
811
  // displays
813
- let dsections = data[2].split(/\n\s*\n/);
812
+ let dsections = data[2].replace(/\r/g, '').split(/\n\s*\n/);
814
813
  // result.displays = parseLinesWindowsDisplays(dsections);
815
- dsections.shift();
816
- dsections.pop();
814
+ if (dsections[0].trim() === '') { dsections.shift(); }
815
+ if (dsections.length && dsections[dsections.length - 1].trim() === '') { dsections.pop(); }
817
816
 
818
817
  // monitor (powershell)
819
- let msections = data[3].split('Active ');
818
+ let msections = data[3].replace(/\r/g, '').split('Active ');
820
819
  msections.shift();
821
820
 
822
821
  // forms.screens (powershell)
823
- let ssections = data[4].split('BitsPerPixel ');
822
+ let ssections = data[4].replace(/\r/g, '').split('BitsPerPixel ');
824
823
  ssections.shift();
825
824
 
826
825
  // connection params (powershell) - video type
827
- let tsections = data[5].split(/\n\s*\n/);
826
+ let tsections = data[5].replace(/\r/g, '').split(/\n\s*\n/);
828
827
  tsections.shift();
829
828
 
830
829
  // monitor ID (powershell) - model / vendor
831
- const res = data[6].split(/\r\n/);
830
+ const res = data[6].replace(/\r/g, '').split(/\n/);
832
831
  let isections = [];
833
832
  res.forEach(element => {
834
833
  const parts = element.split('|');
@@ -842,6 +841,7 @@ function graphics(callback) {
842
841
  });
843
842
  }
844
843
  });
844
+
845
845
  result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections);
846
846
 
847
847
  if (result.displays.length === 1) {
@@ -889,7 +889,7 @@ function graphics(callback) {
889
889
  for (const i in vections) {
890
890
  if ({}.hasOwnProperty.call(vections, i)) {
891
891
  if (vections[i].trim() !== '') {
892
- const lines = vections[i].trim().split(os.EOL);
892
+ const lines = vections[i].trim().split('\n');
893
893
  const matchingDeviceId = util.getValue(lines, 'MatchingDeviceId').match(/PCI\\(VEN_[0-9A-F]{4})&(DEV_[0-9A-F]{4})(?:&(SUBSYS_[0-9A-F]{8}))?(?:&(REV_[0-9A-F]{2}))?/i);
894
894
  if (matchingDeviceId) {
895
895
  const quadWordmemorySize = parseInt(util.getValue(lines, 'HardwareInformation.qwMemorySize'));
@@ -912,12 +912,12 @@ function graphics(callback) {
912
912
  for (let i in sections) {
913
913
  if ({}.hasOwnProperty.call(sections, i)) {
914
914
  if (sections[i].trim() !== '') {
915
- let lines = sections[i].trim().split('\r\n');
916
- let pnpDeviceId = util.getValue(lines, 'PNPDeviceID', '=').match(/PCI\\(VEN_[0-9A-F]{4})&(DEV_[0-9A-F]{4})(?:&(SUBSYS_[0-9A-F]{8}))?(?:&(REV_[0-9A-F]{2}))?/i);
915
+ let lines = sections[i].trim().split('\n');
916
+ let pnpDeviceId = util.getValue(lines, 'PNPDeviceID', ':').match(/PCI\\(VEN_[0-9A-F]{4})&(DEV_[0-9A-F]{4})(?:&(SUBSYS_[0-9A-F]{8}))?(?:&(REV_[0-9A-F]{2}))?/i);
917
917
  let subDeviceId = null;
918
918
  let memorySize = null;
919
919
  if (pnpDeviceId) {
920
- subDeviceId = pnpDeviceId[3];
920
+ subDeviceId = pnpDeviceId[3] || '';
921
921
  if (subDeviceId) {
922
922
  subDeviceId = subDeviceId.split('_')[1];
923
923
  }
@@ -959,17 +959,17 @@ function graphics(callback) {
959
959
  }
960
960
 
961
961
  controllers.push({
962
- vendor: util.getValue(lines, 'AdapterCompatibility', '='),
963
- model: util.getValue(lines, 'name', '='),
964
- bus: util.getValue(lines, 'PNPDeviceID', '=').startsWith('PCI') ? 'PCI' : '',
965
- vram: (memorySize == null ? util.toInt(util.getValue(lines, 'AdapterRAM', '=')) : memorySize) / 1024 / 1024,
966
- vramDynamic: (util.getValue(lines, 'VideoMemoryType', '=') === '2'),
962
+ vendor: util.getValue(lines, 'AdapterCompatibility', ':'),
963
+ model: util.getValue(lines, 'name', ':'),
964
+ bus: util.getValue(lines, 'PNPDeviceID', ':').startsWith('PCI') ? 'PCI' : '',
965
+ vram: (memorySize == null ? util.toInt(util.getValue(lines, 'AdapterRAM', ':')) : memorySize) / 1024 / 1024,
966
+ vramDynamic: (util.getValue(lines, 'VideoMemoryType', ':') === '2'),
967
967
  subDeviceId
968
968
  });
969
- _resolutionX = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', '=')) || _resolutionX;
970
- _resolutionY = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', '=')) || _resolutionY;
971
- _refreshRate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', '=')) || _refreshRate;
972
- _pixelDepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', '=')) || _pixelDepth;
969
+ _resolutionX = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', ':')) || _resolutionX;
970
+ _resolutionY = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', ':')) || _resolutionY;
971
+ _refreshRate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', ':')) || _refreshRate;
972
+ _pixelDepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', ':')) || _pixelDepth;
973
973
  }
974
974
  }
975
975
  }
@@ -984,12 +984,12 @@ function graphics(callback) {
984
984
  let resolutionX = 0;
985
985
  let resolutionY = 0;
986
986
  if (dsections && dsections.length) {
987
- let linesDisplay = dsections[0].split(os.EOL);
988
- vendor = util.getValue(linesDisplay, 'MonitorManufacturer', '=');
989
- model = util.getValue(linesDisplay, 'Name', '=');
990
- deviceID = util.getValue(linesDisplay, 'PNPDeviceID', '=').replace(/&/g, '&').toLowerCase();
991
- resolutionX = util.toInt(util.getValue(linesDisplay, 'ScreenWidth', '='));
992
- resolutionY = util.toInt(util.getValue(linesDisplay, 'ScreenHeight', '='));
987
+ let linesDisplay = dsections[0].split('\n');
988
+ vendor = util.getValue(linesDisplay, 'MonitorManufacturer', ':');
989
+ model = util.getValue(linesDisplay, 'Name', ':');
990
+ deviceID = util.getValue(linesDisplay, 'PNPDeviceID', ':').replace(/&/g, '&').toLowerCase();
991
+ resolutionX = util.toInt(util.getValue(linesDisplay, 'ScreenWidth', ':'));
992
+ resolutionY = util.toInt(util.getValue(linesDisplay, 'ScreenHeight', ':'));
993
993
  }
994
994
  for (let i = 0; i < ssections.length; i++) {
995
995
  if (ssections[i].trim() !== '') {
@@ -1000,10 +1000,10 @@ function graphics(callback) {
1000
1000
  if (tsections.length === 0 || tsections[i] === undefined) {
1001
1001
  tsections[i] = 'Unknown';
1002
1002
  }
1003
- let linesScreen = ssections[i].split(os.EOL);
1004
- let linesMonitor = msections[i].split(os.EOL);
1003
+ let linesScreen = ssections[i].split('\n');
1004
+ let linesMonitor = msections[i].split('\n');
1005
1005
 
1006
- let linesConnection = tsections[i].split(os.EOL);
1006
+ let linesConnection = tsections[i].split('\n');
1007
1007
  const bitsPerPixel = util.getValue(linesScreen, 'BitsPerPixel');
1008
1008
  const bounds = util.getValue(linesScreen, 'Bounds').replace('{', '').replace('}', '').split(',');
1009
1009
  const primary = util.getValue(linesScreen, 'Primary');
@@ -1027,15 +1027,15 @@ function graphics(callback) {
1027
1027
  main: primary.toLowerCase() === 'true',
1028
1028
  builtin: videoOutputTechnology === '2147483648',
1029
1029
  connection: videoOutputTechnology && videoTypes[videoOutputTechnology] ? videoTypes[videoOutputTechnology] : '',
1030
- resolutionX: util.toInt(util.getValue(bounds, 'Width', '=')),
1031
- resolutionY: util.toInt(util.getValue(bounds, 'Height', '=')),
1030
+ resolutionX: util.toInt(util.getValue(bounds, 'Width', ':')),
1031
+ resolutionY: util.toInt(util.getValue(bounds, 'Height', ':')),
1032
1032
  sizeX: sizeX ? parseInt(sizeX, 10) : null,
1033
1033
  sizeY: sizeY ? parseInt(sizeY, 10) : null,
1034
1034
  pixelDepth: bitsPerPixel,
1035
- currentResX: util.toInt(util.getValue(bounds, 'Width', '=')),
1036
- currentResY: util.toInt(util.getValue(bounds, 'Height', '=')),
1037
- positionX: util.toInt(util.getValue(bounds, 'X', '=')),
1038
- positionY: util.toInt(util.getValue(bounds, 'Y', '=')),
1035
+ currentResX: util.toInt(util.getValue(bounds, 'Width', ':')),
1036
+ currentResY: util.toInt(util.getValue(bounds, 'Height', ':')),
1037
+ positionX: util.toInt(util.getValue(bounds, 'X', ':')),
1038
+ positionY: util.toInt(util.getValue(bounds, 'Y', ':')),
1039
1039
  });
1040
1040
  }
1041
1041
  }
@@ -1057,7 +1057,6 @@ function graphics(callback) {
1057
1057
  }
1058
1058
  return displays;
1059
1059
  }
1060
-
1061
1060
  }
1062
1061
 
1063
1062
  exports.graphics = graphics;
package/lib/index.d.ts CHANGED
@@ -655,7 +655,7 @@ export namespace Systeminformation {
655
655
  bridgeNfIptables: boolean;
656
656
  bridgeNfIp6tables: boolean;
657
657
  debug: boolean;
658
- mfd: number;
658
+ nfd: number;
659
659
  oomKillDisable: boolean;
660
660
  ngoroutines: number;
661
661
  systemTime: string;
package/lib/memory.js CHANGED
@@ -256,14 +256,14 @@ function mem(callback) {
256
256
  let swaptotal = 0;
257
257
  let swapused = 0;
258
258
  try {
259
- util.wmic('pagefile get AllocatedBaseSize, CurrentUsage').then((stdout, error) => {
259
+ util.powerShell('Get-CimInstance Win32_PageFileUsage | Select AllocatedBaseSize, CurrentUsage').then((stdout, error) => {
260
260
  if (!error) {
261
261
  let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
262
262
  lines.forEach(function (line) {
263
263
  if (line !== '') {
264
264
  line = line.trim().split(/\s\s+/);
265
- swaptotal = swaptotal + parseInt(line[0], 10);
266
- swapused = swapused + parseInt(line[1], 10);
265
+ swaptotal = swaptotal + (parseInt(line[0], 10) || 0);
266
+ swapused = swapused + (parseInt(line[1], 10) || 0);
267
267
  }
268
268
  });
269
269
  }
@@ -497,28 +497,31 @@ function memLayout(callback) {
497
497
  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('|');
498
498
 
499
499
  try {
500
- util.wmic('memorychip get /value').then((stdout, error) => {
500
+ util.powerShell('Get-WmiObject Win32_PhysicalMemory | fl *').then((stdout, error) => {
501
501
  if (!error) {
502
- let devices = stdout.toString().split('BankL');
502
+ let devices = stdout.toString().split(/\n\s*\n/);
503
503
  devices.shift();
504
504
  devices.forEach(function (device) {
505
505
  let lines = device.split('\r\n');
506
- const dataWidth = util.toInt(util.getValue(lines, 'DataWidth', '='));
507
- const totalWidth = util.toInt(util.getValue(lines, 'TotalWidth', '='));
508
- result.push({
509
- size: parseInt(util.getValue(lines, 'Capacity', '='), 10) || 0,
510
- bank: util.getValue(lines, 'abel', '='), // BankLabel
511
- type: memoryTypes[parseInt(util.getValue(lines, 'MemoryType', '='), 10) || parseInt(util.getValue(lines, 'SMBIOSMemoryType', '='), 10)],
512
- ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false,
513
- clockSpeed: parseInt(util.getValue(lines, 'ConfiguredClockSpeed', '='), 10) || parseInt(util.getValue(lines, 'Speed', '='), 10) || 0,
514
- formFactor: FormFactors[parseInt(util.getValue(lines, 'FormFactor', '='), 10) || 0],
515
- manufacturer: util.getValue(lines, 'Manufacturer', '='),
516
- partNum: util.getValue(lines, 'PartNumber', '='),
517
- serialNum: util.getValue(lines, 'SerialNumber', '='),
518
- voltageConfigured: (parseInt(util.getValue(lines, 'ConfiguredVoltage', '='), 10) || 0) / 1000.0,
519
- voltageMin: (parseInt(util.getValue(lines, 'MinVoltage', '='), 10) || 0) / 1000.0,
520
- voltageMax: (parseInt(util.getValue(lines, 'MaxVoltage', '='), 10) || 0) / 1000.0,
521
- });
506
+ const dataWidth = util.toInt(util.getValue(lines, 'DataWidth', ':'));
507
+ const totalWidth = util.toInt(util.getValue(lines, 'TotalWidth', ':'));
508
+ const size = parseInt(util.getValue(lines, 'Capacity', ':'), 10) || 0;
509
+ if (size) {
510
+ result.push({
511
+ size,
512
+ bank: util.getValue(lines, 'BankLabel', ':'), // BankLabel
513
+ type: memoryTypes[parseInt(util.getValue(lines, 'MemoryType', ':'), 10) || parseInt(util.getValue(lines, 'SMBIOSMemoryType', ':'), 10)],
514
+ ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false,
515
+ clockSpeed: parseInt(util.getValue(lines, 'ConfiguredClockSpeed', ':'), 10) || parseInt(util.getValue(lines, 'Speed', ':'), 10) || 0,
516
+ formFactor: FormFactors[parseInt(util.getValue(lines, 'FormFactor', ':'), 10) || 0],
517
+ manufacturer: util.getValue(lines, 'Manufacturer', ':'),
518
+ partNum: util.getValue(lines, 'PartNumber', ':'),
519
+ serialNum: util.getValue(lines, 'SerialNumber', ':'),
520
+ voltageConfigured: (parseInt(util.getValue(lines, 'ConfiguredVoltage', ':'), 10) || 0) / 1000.0,
521
+ voltageMin: (parseInt(util.getValue(lines, 'MinVoltage', ':'), 10) || 0) / 1000.0,
522
+ voltageMax: (parseInt(util.getValue(lines, 'MaxVoltage', ':'), 10) || 0) / 1000.0,
523
+ });
524
+ }
522
525
  });
523
526
  }
524
527
  if (callback) { callback(result); }