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 |
| -------------- | -------------- | -------- |
| 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.8 | 2017-12-02 | bugfix diskLayout().size (OSX) |
| 3.33.7 | 2017-11-28 | bugfix diskLayout().size |

View File

@ -237,29 +237,31 @@ function blockDevices(callback) {
});
}
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) {
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
lines.forEach(function (line) {
if (line !== '') {
line = line.replace('\r', '').split(',');
let devices = stdout.toString().split(/\n\s*\n/);
devices.forEach(function (device) {
let lines = device.split('\r\n');
let drivetype = util.getValue(lines, 'drivetype', '=');
if (drivetype) {
data.push({
name: line[7],
identifier: line[1],
name: util.getValue(lines, 'name', '='),
identifier: util.getValue(lines, 'caption', '='),
type: 'disk',
fstype: line[5].toLowerCase(),
mount: line[1],
size: line[8],
physical: line[4] === '5' ? 'CD/DVD' : 'HDD',
uuid: line[10],
label: line[9],
fstype: util.getValue(lines, 'filesystem', '=').toLowerCase(),
mount: util.getValue(lines, 'caption', '='),
size: util.getValue(lines, 'size', '='),
physical: (drivetype >= 0 && drivetype <= 6) ? drivetypes[drivetype] : drivetypes[0],
uuid: util.getValue(lines, 'volumeserialnumber', '='),
label: util.getValue(lines, 'volumename', '='),
model: '',
serial: line[10],
removable: line[4] === '2',
serial: util.getValue(lines, 'volumeserialnumber', '='),
removable: drivetype === '2',
protocol: ''
});
}
});
});
}
if (callback) {
callback(data);