refactoring (windows codepage issues) wifi.js

This commit is contained in:
Sebastian Hildebrandt 2021-10-17 19:30:33 +02:00
parent 0a25f008ce
commit 836bd855f1

View File

@ -414,9 +414,8 @@ function wifiNetworks(callback) {
resolve(result);
});
} else if (_windows) {
let cmd = 'chcp 65001 && netsh wlan show networks mode=Bssid';
exec(cmd, util.execOptsWin, function (error, stdout) {
let cmd = 'netsh wlan show networks mode=Bssid';
util.powerShell(cmd).then((stdout, error) => {
const ssidParts = stdout.toString('utf8').split(os.EOL + os.EOL + 'SSID ');
ssidParts.shift();
@ -571,8 +570,12 @@ function wifiConnections(callback) {
});
} else if (_windows) {
let cmd = 'netsh wlan show interfaces';
exec(cmd, util.execOptsWin, function (error, stdout) {
const parts = stdout.toString().split(': \r\n\r\n');
util.powerShell(cmd).then(function (stdout, error) {
const allLines = stdout.toString().split('\r\n')
for (let i = 0; i < allLines.length; i++) {
allLines[i] = allLines[i].trim()
};
const parts = allLines.join('\r\n').split(':\r\n\r\n');
parts.shift();
parts.forEach(part => {
const lines = part.split('\r\n');
@ -667,8 +670,12 @@ function wifiInterfaces(callback) {
});
} else if (_windows) {
let cmd = 'netsh wlan show interfaces';
exec(cmd, util.execOptsWin, function (error, stdout) {
const parts = stdout.toString().split(': \r\n\r\n');
util.powerShell(cmd).then(function (stdout, error) {
const allLines = stdout.toString().split('\r\n')
for (let i = 0; i < allLines.length; i++) {
allLines[i] = allLines[i].trim()
};
const parts = allLines.join('\r\n').split(':\r\n\r\n');
parts.shift();
parts.forEach(part => {
const lines = part.split('\r\n');