Win Powershell UTF8 support

This commit is contained in:
Sebastian Hildebrandt 2021-10-09 08:22:39 +02:00
parent 41376979e2
commit b4cd550b16
2 changed files with 3 additions and 2 deletions

View File

@ -283,7 +283,7 @@ function users(callback) {
}
if (_windows) {
try {
util.execWin('query user', util.execOptsWin, function (error, stdout) {
util.powerShell('query user').then(stdout => {
if (stdout) {
// lines / split
let lines = stdout.toString().split('\r\n');

View File

@ -341,6 +341,7 @@ function getVboxmanage() {
function powerShell(cmd) {
let result = '';
const psUTF8 = '$OutputEncoding = [System.Console]::OutputEncoding = [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8 ; ';
return new Promise((resolve) => {
process.nextTick(() => {
@ -375,7 +376,7 @@ function powerShell(cmd) {
resolve(result);
});
try {
child.stdin.write(cmd + os.EOL);
child.stdin.write(psUTF8 + cmd + os.EOL);
child.stdin.write('exit' + os.EOL);
child.stdin.end();
} catch (e) {