diff --git a/lib/filesystem.js b/lib/filesystem.js index bb772db..7d02959 100755 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -395,25 +395,26 @@ function blockDevices(callback) { if (_windows) { let drivetypes = ['Unknown', 'NoRoot', 'Removable', 'Local', 'Network', 'CD/DVD', 'RAM']; try { - util.wmic('logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /value').then((stdout, error) => { + // util.wmic('logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /value').then((stdout, error) => { + util.powerShell('Get-CimInstance -ClassName Win32_LogicalDisk | Format-List *').then((stdout, error) => { if (!error) { let devices = stdout.toString().split(/\n\s*\n/); devices.forEach(function (device) { let lines = device.split('\r\n'); - let drivetype = util.getValue(lines, 'drivetype', '='); + let drivetype = util.getValue(lines, 'drivetype', ':'); if (drivetype) { data.push({ - name: util.getValue(lines, 'name', '='), - identifier: util.getValue(lines, 'caption', '='), + name: util.getValue(lines, 'name', ':'), + identifier: util.getValue(lines, 'caption', ':'), type: 'disk', - fsType: util.getValue(lines, 'filesystem', '=').toLowerCase(), - mount: util.getValue(lines, 'caption', '='), - size: util.getValue(lines, 'size', '='), + 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', '='), + uuid: util.getValue(lines, 'volumeserialnumber', ':'), + label: util.getValue(lines, 'volumename', ':'), model: '', - serial: util.getValue(lines, 'volumeserialnumber', '='), + serial: util.getValue(lines, 'volumeserialnumber', ':'), removable: drivetype === '2', protocol: '' }); diff --git a/lib/util.js b/lib/util.js index 5952034..17f7920 100644 --- a/lib/util.js +++ b/lib/util.js @@ -355,7 +355,7 @@ function getVboxmanage() { function powerShell(cmd) { let result = ''; - const psUTF8 = '$OutputEncoding = [System.Console]::OutputEncoding = [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8 ; '; + const toUTF8 = '$OutputEncoding = [System.Console]::OutputEncoding = [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8 ; '; return new Promise((resolve) => { process.nextTick(() => { @@ -390,7 +390,7 @@ function powerShell(cmd) { resolve(result); }); try { - child.stdin.write(psUTF8 + cmd + os.EOL); + child.stdin.write(toUTF8 + cmd + os.EOL); child.stdin.write('exit' + os.EOL); child.stdin.end(); } catch (e) {