systeminformation 5.9.7 → 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/CHANGELOG.md +3 -2
- package/lib/audio.js +219 -219
- package/lib/battery.js +309 -309
- package/lib/bluetooth.js +183 -183
- package/lib/cpu.js +43 -41
- package/lib/dockerSocket.js +1 -1
- package/lib/filesystem.js +1265 -1264
- package/lib/graphics.js +41 -42
- package/lib/index.d.ts +1 -1
- package/lib/memory.js +24 -21
- package/lib/network.js +1589 -1589
- package/lib/osinfo.js +1150 -1150
- package/lib/printer.js +212 -212
- package/lib/processes.js +1240 -1240
- package/lib/system.js +839 -841
- package/lib/usb.js +305 -305
- package/lib/users.js +187 -81
- package/lib/util.js +21 -6
- package/lib/wifi.js +15 -8
- package/package.json +1 -1
package/lib/users.js
CHANGED
|
@@ -26,43 +26,43 @@ const _openbsd = (_platform === 'openbsd');
|
|
|
26
26
|
const _netbsd = (_platform === 'netbsd');
|
|
27
27
|
const _sunos = (_platform === 'sunos');
|
|
28
28
|
|
|
29
|
-
let _winDateFormat = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
29
|
+
// let _winDateFormat = {
|
|
30
|
+
// dateFormat: '',
|
|
31
|
+
// dateSeperator: '',
|
|
32
|
+
// timeFormat: '',
|
|
33
|
+
// timeSeperator: '',
|
|
34
|
+
// amDesignator: '',
|
|
35
|
+
// pmDesignator: ''
|
|
36
|
+
// };
|
|
37
37
|
|
|
38
38
|
// --------------------------
|
|
39
39
|
// array of users online = sessions
|
|
40
40
|
|
|
41
|
-
function getWinCulture() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
// function getWinCulture() {
|
|
42
|
+
// return new Promise((resolve) => {
|
|
43
|
+
// process.nextTick(() => {
|
|
44
|
+
// if (!_winDateFormat.dateFormat) {
|
|
45
|
+
// util.powerShell('(get-culture).DateTimeFormat')
|
|
46
|
+
// .then(data => {
|
|
47
|
+
// let lines = data.toString().split('\r\n');
|
|
48
|
+
// _winDateFormat.dateFormat = util.getValue(lines, 'ShortDatePattern', ':');
|
|
49
|
+
// _winDateFormat.dateSeperator = util.getValue(lines, 'DateSeparator', ':');
|
|
50
|
+
// _winDateFormat.timeFormat = util.getValue(lines, 'ShortTimePattern', ':');
|
|
51
|
+
// _winDateFormat.timeSeperator = util.getValue(lines, 'TimeSeparator', ':');
|
|
52
|
+
// _winDateFormat.amDesignator = util.getValue(lines, 'AMDesignator', ':');
|
|
53
|
+
// _winDateFormat.pmDesignator = util.getValue(lines, 'PMDesignator', ':');
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
55
|
+
// resolve(_winDateFormat);
|
|
56
|
+
// })
|
|
57
|
+
// .catch(() => {
|
|
58
|
+
// resolve(_winDateFormat);
|
|
59
|
+
// });
|
|
60
|
+
// } else {
|
|
61
|
+
// resolve(_winDateFormat);
|
|
62
|
+
// }
|
|
63
|
+
// });
|
|
64
|
+
// });
|
|
65
|
+
// }
|
|
66
66
|
|
|
67
67
|
function parseUsersLinux(lines, phase) {
|
|
68
68
|
let result = [];
|
|
@@ -176,43 +176,43 @@ function parseUsersDarwin(lines) {
|
|
|
176
176
|
return result;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
function parseUsersWin(lines, culture) {
|
|
179
|
+
// function parseUsersWin(lines, culture) {
|
|
180
180
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
181
|
+
// let result = [];
|
|
182
|
+
// const header = lines[0];
|
|
183
|
+
// const headerDelimiter = [];
|
|
184
|
+
// if (header) {
|
|
185
|
+
// const start = (header[0] === ' ') ? 1 : 0;
|
|
186
|
+
// headerDelimiter.push(start - 1);
|
|
187
|
+
// let nextSpace = 0;
|
|
188
|
+
// for (let i = start + 1; i < header.length; i++) {
|
|
189
|
+
// if (header[i] === ' ' && ((header[i - 1] === ' ') || (header[i - 1] === '.'))) {
|
|
190
|
+
// nextSpace = i;
|
|
191
|
+
// } else {
|
|
192
|
+
// if (nextSpace) {
|
|
193
|
+
// headerDelimiter.push(nextSpace);
|
|
194
|
+
// nextSpace = 0;
|
|
195
|
+
// }
|
|
196
|
+
// }
|
|
197
|
+
// }
|
|
198
|
+
// for (let i = 1; i < lines.length; i++) {
|
|
199
|
+
// if (lines[i].trim()) {
|
|
200
|
+
// const user = lines[i].substring(headerDelimiter[0] + 1, headerDelimiter[1]).trim() || '';
|
|
201
|
+
// const tty = lines[i].substring(headerDelimiter[1] + 1, headerDelimiter[2] - 2).trim() || '';
|
|
202
|
+
// const dateTime = util.parseDateTime(lines[i].substring(headerDelimiter[5] + 1, 2000).trim(), culture) || '';
|
|
203
|
+
// result.push({
|
|
204
|
+
// user: user,
|
|
205
|
+
// tty: tty,
|
|
206
|
+
// date: dateTime.date,
|
|
207
|
+
// time: dateTime.time,
|
|
208
|
+
// ip: '',
|
|
209
|
+
// command: ''
|
|
210
|
+
// });
|
|
211
|
+
// }
|
|
212
|
+
// }
|
|
213
|
+
// }
|
|
214
|
+
// return result;
|
|
215
|
+
// }
|
|
216
216
|
|
|
217
217
|
function users(callback) {
|
|
218
218
|
|
|
@@ -283,21 +283,62 @@ function users(callback) {
|
|
|
283
283
|
}
|
|
284
284
|
if (_windows) {
|
|
285
285
|
try {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
286
|
+
const workload = [];
|
|
287
|
+
// workload.push(util.powerShell('Get-CimInstance -ClassName Win32_Account | fl *'));
|
|
288
|
+
workload.push(util.powerShell('Get-WmiObject Win32_LogonSession | fl *'));
|
|
289
|
+
workload.push(util.powerShell('Get-WmiObject Win32_LoggedOnUser | fl *'));
|
|
290
|
+
workload.push(util.powerShell('Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl'));
|
|
291
|
+
Promise.all(
|
|
292
|
+
workload
|
|
293
|
+
).then(data => {
|
|
294
|
+
// controller + vram
|
|
295
|
+
// let accounts = parseWinAccounts(data[0].split(/\n\s*\n/));
|
|
296
|
+
let sessions = parseWinSessions(data[0].split(/\n\s*\n/));
|
|
297
|
+
let loggedons = parseWinLoggedOn(data[1].split(/\n\s*\n/));
|
|
298
|
+
let users = parseWinUsers(data[2].split(/\n\s*\n/));
|
|
299
|
+
for (let id in loggedons) {
|
|
300
|
+
if ({}.hasOwnProperty.call(loggedons, id)) {
|
|
301
|
+
loggedons[id].dateTime = {}.hasOwnProperty.call(sessions, id) ? sessions[id] : '';
|
|
302
|
+
}
|
|
299
303
|
}
|
|
304
|
+
users.forEach(user => {
|
|
305
|
+
let dateTime = '';
|
|
306
|
+
for (let id in loggedons) {
|
|
307
|
+
if ({}.hasOwnProperty.call(loggedons, id)) {
|
|
308
|
+
if (loggedons[id].user === user.user && (!dateTime || dateTime < loggedons[id].dateTime)) {
|
|
309
|
+
dateTime = loggedons[id].dateTime;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
result.push({
|
|
315
|
+
user: user.user,
|
|
316
|
+
tty: '',
|
|
317
|
+
date: `${dateTime.substr(0, 4)}-${dateTime.substr(4, 2)}-${dateTime.substr(6, 2)}`,
|
|
318
|
+
time: `${dateTime.substr(8, 2)}:${dateTime.substr(10, 2)}`,
|
|
319
|
+
ip: '',
|
|
320
|
+
command: ''
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
if (callback) { callback(result); }
|
|
324
|
+
resolve(result);
|
|
325
|
+
|
|
300
326
|
});
|
|
327
|
+
// util.powerShell('query user').then(stdout => {
|
|
328
|
+
// if (stdout) {
|
|
329
|
+
// // lines / split
|
|
330
|
+
// let lines = stdout.toString().split('\r\n');
|
|
331
|
+
// getWinCulture()
|
|
332
|
+
// .then(culture => {
|
|
333
|
+
// result = parseUsersWin(lines, culture);
|
|
334
|
+
// if (callback) { callback(result); }
|
|
335
|
+
// resolve(result);
|
|
336
|
+
// });
|
|
337
|
+
// } else {
|
|
338
|
+
// if (callback) { callback(result); }
|
|
339
|
+
// resolve(result);
|
|
340
|
+
// }
|
|
341
|
+
// });
|
|
301
342
|
} catch (e) {
|
|
302
343
|
if (callback) { callback(result); }
|
|
303
344
|
resolve(result);
|
|
@@ -308,4 +349,69 @@ function users(callback) {
|
|
|
308
349
|
});
|
|
309
350
|
}
|
|
310
351
|
|
|
352
|
+
// function parseWinAccounts(accountParts) {
|
|
353
|
+
// const accounts = [];
|
|
354
|
+
// accountParts.forEach(account => {
|
|
355
|
+
// const lines = account.split('\r\n');
|
|
356
|
+
// const name = util.getValue(lines, 'name', ':', true);
|
|
357
|
+
// const domain = util.getValue(lines, 'domain', ':', true);
|
|
358
|
+
// accounts.push(`${domain}\${name}`);
|
|
359
|
+
// });
|
|
360
|
+
// return accounts;
|
|
361
|
+
// }
|
|
362
|
+
|
|
363
|
+
function parseWinSessions(sessionParts) {
|
|
364
|
+
const sessions = {};
|
|
365
|
+
sessionParts.forEach(session => {
|
|
366
|
+
const lines = session.split('\r\n');
|
|
367
|
+
const id = util.getValue(lines, 'LogonId');
|
|
368
|
+
const starttime = util.getValue(lines, 'starttime');
|
|
369
|
+
if (id) {
|
|
370
|
+
sessions[id] = starttime;
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
return sessions;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function parseWinUsers(userParts) {
|
|
377
|
+
const users = [];
|
|
378
|
+
userParts.forEach(user => {
|
|
379
|
+
const lines = user.split('\r\n');
|
|
380
|
+
|
|
381
|
+
const domain = util.getValue(lines, 'domain', ':', true);
|
|
382
|
+
const username = util.getValue(lines, 'username', ':', true);
|
|
383
|
+
if (username) {
|
|
384
|
+
users.push({
|
|
385
|
+
domain,
|
|
386
|
+
user: username
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
return users;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function parseWinLoggedOn(loggedonParts) {
|
|
394
|
+
const loggedons = {};
|
|
395
|
+
loggedonParts.forEach(loggedon => {
|
|
396
|
+
const lines = loggedon.split('\r\n');
|
|
397
|
+
|
|
398
|
+
const antecendent = util.getValue(lines, 'antecedent', ':', true);
|
|
399
|
+
let parts = antecendent.split(',');
|
|
400
|
+
const domainParts = parts.length > 1 ? parts[0].split('=') : [];
|
|
401
|
+
const nameParts = parts.length > 1 ? parts[1].split('=') : [];
|
|
402
|
+
const domain = domainParts.length > 1 ? domainParts[1].replace(/"/g, '') : '';
|
|
403
|
+
const name = nameParts.length > 1 ? nameParts[1].replace(/"/g, '') : '';
|
|
404
|
+
const dependent = util.getValue(lines, 'dependent', ':', true);
|
|
405
|
+
parts = dependent.split('=');
|
|
406
|
+
const id = parts.length > 1 ? parts[1].replace(/"/g, '') : '';
|
|
407
|
+
if (id) {
|
|
408
|
+
loggedons[id] = {
|
|
409
|
+
domain,
|
|
410
|
+
user: name
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
return loggedons;
|
|
415
|
+
}
|
|
416
|
+
|
|
311
417
|
exports.users = users;
|
package/lib/util.js
CHANGED
|
@@ -319,14 +319,13 @@ function getWmic() {
|
|
|
319
319
|
return wmicPath;
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
function wmic(command
|
|
323
|
-
options = options || execOptsWin;
|
|
322
|
+
function wmic(command) {
|
|
324
323
|
return new Promise((resolve) => {
|
|
325
324
|
process.nextTick(() => {
|
|
326
325
|
try {
|
|
327
|
-
|
|
328
|
-
resolve(stdout,
|
|
329
|
-
})
|
|
326
|
+
powerShell(getWmic() + ' ' + command).then(stdout => {
|
|
327
|
+
resolve(stdout, '');
|
|
328
|
+
});
|
|
330
329
|
} catch (e) {
|
|
331
330
|
resolve('', e);
|
|
332
331
|
}
|
|
@@ -334,6 +333,21 @@ function wmic(command, options) {
|
|
|
334
333
|
});
|
|
335
334
|
}
|
|
336
335
|
|
|
336
|
+
// function wmic(command, options) {
|
|
337
|
+
// options = options || execOptsWin;
|
|
338
|
+
// return new Promise((resolve) => {
|
|
339
|
+
// process.nextTick(() => {
|
|
340
|
+
// try {
|
|
341
|
+
// exec(WINDIR + '\\system32\\chcp.com 65001 | ' + getWmic() + ' ' + command, options, function (error, stdout) {
|
|
342
|
+
// resolve(stdout, error);
|
|
343
|
+
// }).stdin.end();
|
|
344
|
+
// } catch (e) {
|
|
345
|
+
// resolve('', e);
|
|
346
|
+
// }
|
|
347
|
+
// });
|
|
348
|
+
// });
|
|
349
|
+
// }
|
|
350
|
+
|
|
337
351
|
function getVboxmanage() {
|
|
338
352
|
return _windows ? `"${process.env.VBOX_INSTALL_PATH || process.env.VBOX_MSI_INSTALL_PATH}\\VBoxManage.exe"` : 'vboxmanage';
|
|
339
353
|
}
|
|
@@ -341,6 +355,7 @@ function getVboxmanage() {
|
|
|
341
355
|
function powerShell(cmd) {
|
|
342
356
|
|
|
343
357
|
let result = '';
|
|
358
|
+
const toUTF8 = '$OutputEncoding = [System.Console]::OutputEncoding = [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8 ; ';
|
|
344
359
|
|
|
345
360
|
return new Promise((resolve) => {
|
|
346
361
|
process.nextTick(() => {
|
|
@@ -375,7 +390,7 @@ function powerShell(cmd) {
|
|
|
375
390
|
resolve(result);
|
|
376
391
|
});
|
|
377
392
|
try {
|
|
378
|
-
child.stdin.write(cmd + os.EOL);
|
|
393
|
+
child.stdin.write(toUTF8 + cmd + os.EOL);
|
|
379
394
|
child.stdin.write('exit' + os.EOL);
|
|
380
395
|
child.stdin.end();
|
|
381
396
|
} catch (e) {
|
package/lib/wifi.js
CHANGED
|
@@ -414,16 +414,15 @@ function wifiNetworks(callback) {
|
|
|
414
414
|
resolve(result);
|
|
415
415
|
});
|
|
416
416
|
} else if (_windows) {
|
|
417
|
-
let cmd = '
|
|
418
|
-
|
|
419
|
-
|
|
417
|
+
let cmd = 'netsh wlan show networks mode=Bssid';
|
|
418
|
+
util.powerShell(cmd).then((stdout) => {
|
|
420
419
|
const ssidParts = stdout.toString('utf8').split(os.EOL + os.EOL + 'SSID ');
|
|
421
420
|
ssidParts.shift();
|
|
422
421
|
|
|
423
422
|
ssidParts.forEach(ssidPart => {
|
|
424
423
|
const ssidLines = ssidPart.split(os.EOL);
|
|
425
424
|
if (ssidLines && ssidLines.length >= 8 && ssidLines[0].indexOf(':') >= 0) {
|
|
426
|
-
const bssidsParts = ssidPart.split('BSSID
|
|
425
|
+
const bssidsParts = ssidPart.split(' BSSID');
|
|
427
426
|
bssidsParts.shift();
|
|
428
427
|
|
|
429
428
|
bssidsParts.forEach((bssidPart) => {
|
|
@@ -571,8 +570,12 @@ function wifiConnections(callback) {
|
|
|
571
570
|
});
|
|
572
571
|
} else if (_windows) {
|
|
573
572
|
let cmd = 'netsh wlan show interfaces';
|
|
574
|
-
|
|
575
|
-
const
|
|
573
|
+
util.powerShell(cmd).then(function (stdout) {
|
|
574
|
+
const allLines = stdout.toString().split('\r\n');
|
|
575
|
+
for (let i = 0; i < allLines.length; i++) {
|
|
576
|
+
allLines[i] = allLines[i].trim();
|
|
577
|
+
}
|
|
578
|
+
const parts = allLines.join('\r\n').split(':\r\n\r\n');
|
|
576
579
|
parts.shift();
|
|
577
580
|
parts.forEach(part => {
|
|
578
581
|
const lines = part.split('\r\n');
|
|
@@ -667,8 +670,12 @@ function wifiInterfaces(callback) {
|
|
|
667
670
|
});
|
|
668
671
|
} else if (_windows) {
|
|
669
672
|
let cmd = 'netsh wlan show interfaces';
|
|
670
|
-
|
|
671
|
-
const
|
|
673
|
+
util.powerShell(cmd).then(function (stdout) {
|
|
674
|
+
const allLines = stdout.toString().split('\r\n');
|
|
675
|
+
for (let i = 0; i < allLines.length; i++) {
|
|
676
|
+
allLines[i] = allLines[i].trim();
|
|
677
|
+
}
|
|
678
|
+
const parts = allLines.join('\r\n').split(':\r\n\r\n');
|
|
672
679
|
parts.shift();
|
|
673
680
|
parts.forEach(part => {
|
|
674
681
|
const lines = part.split('\r\n');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.8",
|
|
4
4
|
"description": "Advanced, lightweight system and OS information library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|