wmic added default windows path (windows)

This commit is contained in:
Sebastian Hildebrandt
2020-11-27 16:05:56 +01:00
parent 5093145506
commit c6fccc0513
4 changed files with 11 additions and 3 deletions
+4 -2
View File
@@ -33,6 +33,8 @@ let _cores = 0;
let wmicPath = '';
let codepage = '';
const WINDIR = process.env.WINDIR || 'C:\\Windows';
const execOptsWin = {
windowsHide: true,
maxBuffer: 1024 * 20000,
@@ -295,7 +297,7 @@ function findObjectByKey(array, key, value) {
function getWmic() {
if (os.type() === 'Windows_NT' && !wmicPath) {
wmicPath = process.env.WINDIR + '\\system32\\wbem\\wmic.exe';
wmicPath = WINDIR + '\\system32\\wbem\\wmic.exe';
if (!fs.existsSync(wmicPath)) {
try {
const wmicPathArray = execSync('WHERE WMIC').toString().split('\r\n');
@@ -317,7 +319,7 @@ function wmic(command, options) {
return new Promise((resolve) => {
process.nextTick(() => {
try {
exec(process.env.WINDIR + '\\system32\\chcp.com 65001 | ' + getWmic() + ' ' + command, options, function (error, stdout) {
exec(WINDIR + '\\system32\\chcp.com 65001 | ' + getWmic() + ' ' + command, options, function (error, stdout) {
resolve(stdout, error);
}).stdin.end();
} catch (e) {