bugfix WMIC blockDevice parse (Windows 7)

This commit is contained in:
Sebastian Hildebrandt 2017-12-14 15:19:53 +01:00
parent 0fb74227ac
commit 5d818d79b3
2 changed files with 19 additions and 16 deletions

View File

@ -99,6 +99,7 @@ Other changes
| Version | Date | Comment | | Version | Date | Comment |
| -------------- | -------------- | -------- | | -------------- | -------------- | -------- |
| 3.33.10 | 2017-12-14 | bugfix WMIC blockDevice parse (Windows 7) |
| 3.33.9 | 2017-12-14 | bugfix WMIC not found (Windows) | | 3.33.9 | 2017-12-14 | bugfix WMIC not found (Windows) |
| 3.33.8 | 2017-12-02 | bugfix diskLayout().size (OSX) | | 3.33.8 | 2017-12-02 | bugfix diskLayout().size (OSX) |
| 3.33.7 | 2017-11-28 | bugfix diskLayout().size | | 3.33.7 | 2017-11-28 | bugfix diskLayout().size |

View File

@ -237,29 +237,31 @@ function blockDevices(callback) {
}); });
} }
if (_windows) { if (_windows) {
exec(util.getWmic() + ' logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /format:csv', function (error, stdout) { let drivetypes = ['Unknown', 'NoRoot', 'Removable', 'HDD', 'Network', 'CD/DVD', 'RAM']
exec(util.getWmic() + ' logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /value', function (error, stdout) {
if (!error) { if (!error) {
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0); let devices = stdout.toString().split(/\n\s*\n/);
lines.forEach(function (line) { devices.forEach(function (device) {
if (line !== '') { let lines = device.split('\r\n');
line = line.replace('\r', '').split(','); let drivetype = util.getValue(lines, 'drivetype', '=');
if (drivetype) {
data.push({ data.push({
name: line[7], name: util.getValue(lines, 'name', '='),
identifier: line[1], identifier: util.getValue(lines, 'caption', '='),
type: 'disk', type: 'disk',
fstype: line[5].toLowerCase(), fstype: util.getValue(lines, 'filesystem', '=').toLowerCase(),
mount: line[1], mount: util.getValue(lines, 'caption', '='),
size: line[8], size: util.getValue(lines, 'size', '='),
physical: line[4] === '5' ? 'CD/DVD' : 'HDD', physical: (drivetype >= 0 && drivetype <= 6) ? drivetypes[drivetype] : drivetypes[0],
uuid: line[10], uuid: util.getValue(lines, 'volumeserialnumber', '='),
label: line[9], label: util.getValue(lines, 'volumename', '='),
model: '', model: '',
serial: line[10], serial: util.getValue(lines, 'volumeserialnumber', '='),
removable: line[4] === '2', removable: drivetype === '2',
protocol: '' protocol: ''
}); });
} }
}); });
} }
if (callback) { if (callback) {
callback(data); callback(data);