UTF8 windows blockdevice fix-1
This commit is contained in:
parent
e1f03db3a1
commit
913d6b5362
@ -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: ''
|
||||
});
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user