UTF8 windows blockdevice fix-1
This commit is contained in:
parent
e1f03db3a1
commit
913d6b5362
@ -395,25 +395,26 @@ function blockDevices(callback) {
|
|||||||
if (_windows) {
|
if (_windows) {
|
||||||
let drivetypes = ['Unknown', 'NoRoot', 'Removable', 'Local', 'Network', 'CD/DVD', 'RAM'];
|
let drivetypes = ['Unknown', 'NoRoot', 'Removable', 'Local', 'Network', 'CD/DVD', 'RAM'];
|
||||||
try {
|
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) {
|
if (!error) {
|
||||||
let devices = stdout.toString().split(/\n\s*\n/);
|
let devices = stdout.toString().split(/\n\s*\n/);
|
||||||
devices.forEach(function (device) {
|
devices.forEach(function (device) {
|
||||||
let lines = device.split('\r\n');
|
let lines = device.split('\r\n');
|
||||||
let drivetype = util.getValue(lines, 'drivetype', '=');
|
let drivetype = util.getValue(lines, 'drivetype', ':');
|
||||||
if (drivetype) {
|
if (drivetype) {
|
||||||
data.push({
|
data.push({
|
||||||
name: util.getValue(lines, 'name', '='),
|
name: util.getValue(lines, 'name', ':'),
|
||||||
identifier: util.getValue(lines, 'caption', '='),
|
identifier: util.getValue(lines, 'caption', ':'),
|
||||||
type: 'disk',
|
type: 'disk',
|
||||||
fsType: util.getValue(lines, 'filesystem', '=').toLowerCase(),
|
fsType: util.getValue(lines, 'filesystem', ':').toLowerCase(),
|
||||||
mount: util.getValue(lines, 'caption', '='),
|
mount: util.getValue(lines, 'caption', ':'),
|
||||||
size: util.getValue(lines, 'size', '='),
|
size: util.getValue(lines, 'size', ':'),
|
||||||
physical: (drivetype >= 0 && drivetype <= 6) ? drivetypes[drivetype] : drivetypes[0],
|
physical: (drivetype >= 0 && drivetype <= 6) ? drivetypes[drivetype] : drivetypes[0],
|
||||||
uuid: util.getValue(lines, 'volumeserialnumber', '='),
|
uuid: util.getValue(lines, 'volumeserialnumber', ':'),
|
||||||
label: util.getValue(lines, 'volumename', '='),
|
label: util.getValue(lines, 'volumename', ':'),
|
||||||
model: '',
|
model: '',
|
||||||
serial: util.getValue(lines, 'volumeserialnumber', '='),
|
serial: util.getValue(lines, 'volumeserialnumber', ':'),
|
||||||
removable: drivetype === '2',
|
removable: drivetype === '2',
|
||||||
protocol: ''
|
protocol: ''
|
||||||
});
|
});
|
||||||
|
|||||||
@ -355,7 +355,7 @@ function getVboxmanage() {
|
|||||||
function powerShell(cmd) {
|
function powerShell(cmd) {
|
||||||
|
|
||||||
let result = '';
|
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) => {
|
return new Promise((resolve) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
@ -390,7 +390,7 @@ function powerShell(cmd) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
child.stdin.write(psUTF8 + cmd + os.EOL);
|
child.stdin.write(toUTF8 + cmd + os.EOL);
|
||||||
child.stdin.write('exit' + os.EOL);
|
child.stdin.write('exit' + os.EOL);
|
||||||
child.stdin.end();
|
child.stdin.end();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user