wmic added default windows path (windows)
This commit is contained in:
+4
-2
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user