const iconv = require('iconv-lite');
function bianma(data) {
//win一般控制台是cp936编码,根据自己实际情况替换
data = iconv.decode(data, 'cp936');
return data.toString('utf-8');
}
const { exec } = require('child_process');
exec('net session', { encoding: 'buffer' }, (error, so, se) => {
console.log(1, bianma(Buffer.from(error ? JSON.stringify(error) : '')));
console.log(2, so ? bianma(so) : so);
console.log(4, bianma(se), se.length);
});