Win wmic UTF8 support
This commit is contained in:
parent
b4cd550b16
commit
2ff9b239eb
@ -194,7 +194,7 @@ function audio(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
util.wmic('path Win32_SoundDevice get /value', function (error, stdout) {
|
util.wmic('path Win32_SoundDevice get /value').then((stdout, error) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const parts = stdout.toString().split(/\n\s*\n/);
|
const parts = stdout.toString().split(/\n\s*\n/);
|
||||||
for (let i = 0; i < parts.length; i++) {
|
for (let i = 0; i < parts.length; i++) {
|
||||||
|
|||||||
@ -158,7 +158,7 @@ function bluetoothDevices(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
util.wmic('path Win32_PNPEntity get /value', function (error, stdout) {
|
util.wmic('path Win32_PNPEntity get /value').then((stdout, error) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const parts = stdout.toString().split(/\n\s*\n/);
|
const parts = stdout.toString().split(/\n\s*\n/);
|
||||||
for (let i = 0; i < parts.length; i++) {
|
for (let i = 0; i < parts.length; i++) {
|
||||||
|
|||||||
@ -186,7 +186,7 @@ function printer(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
util.wmic('printer get /value', function (error, stdout) {
|
util.wmic('printer get /value').then((stdout, error) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const parts = stdout.toString().split(/\n\s*\n/);
|
const parts = stdout.toString().split(/\n\s*\n/);
|
||||||
for (let i = 0; i < parts.length; i++) {
|
for (let i = 0; i < parts.length; i++) {
|
||||||
|
|||||||
@ -263,7 +263,7 @@ function usb(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
util.wmic('Path CIM_LogicalDevice where "Description like \'USB%\'" get /value', function (error, stdout) {
|
util.wmic('Path CIM_LogicalDevice where "Description like \'USB%\'" get /value').then((stdout, error) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const parts = stdout.toString().split(/\n\s*\n/);
|
const parts = stdout.toString().split(/\n\s*\n/);
|
||||||
for (let i = 0; i < parts.length; i++) {
|
for (let i = 0; i < parts.length; i++) {
|
||||||
|
|||||||
24
lib/util.js
24
lib/util.js
@ -319,14 +319,13 @@ function getWmic() {
|
|||||||
return wmicPath;
|
return wmicPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
function wmic(command, options) {
|
function wmic(command) {
|
||||||
options = options || execOptsWin;
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
try {
|
try {
|
||||||
exec(WINDIR + '\\system32\\chcp.com 65001 | ' + getWmic() + ' ' + command, options, function (error, stdout) {
|
powerShell(getWmic() + ' ' + command).then(stdout => {
|
||||||
resolve(stdout, error);
|
resolve(stdout, '');
|
||||||
}).stdin.end();
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
resolve('', e);
|
resolve('', e);
|
||||||
}
|
}
|
||||||
@ -334,6 +333,21 @@ function wmic(command, options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function wmic(command, options) {
|
||||||
|
// options = options || execOptsWin;
|
||||||
|
// return new Promise((resolve) => {
|
||||||
|
// process.nextTick(() => {
|
||||||
|
// try {
|
||||||
|
// exec(WINDIR + '\\system32\\chcp.com 65001 | ' + getWmic() + ' ' + command, options, function (error, stdout) {
|
||||||
|
// resolve(stdout, error);
|
||||||
|
// }).stdin.end();
|
||||||
|
// } catch (e) {
|
||||||
|
// resolve('', e);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
function getVboxmanage() {
|
function getVboxmanage() {
|
||||||
return _windows ? `"${process.env.VBOX_INSTALL_PATH || process.env.VBOX_MSI_INSTALL_PATH}\\VBoxManage.exe"` : 'vboxmanage';
|
return _windows ? `"${process.env.VBOX_INSTALL_PATH || process.env.VBOX_MSI_INSTALL_PATH}\\VBoxManage.exe"` : 'vboxmanage';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user