wmic path fix - windows

This commit is contained in:
Sebastian Hildebrandt
2019-05-29 19:50:45 +02:00
parent 980828f00e
commit bd842b20a4
4 changed files with 20 additions and 7 deletions
+12 -6
View File
@@ -221,12 +221,18 @@ function findObjectByKey(array, key, value) {
function getWmic() {
if (os.type() === 'Windows_NT' && !wmicPath) {
try {
wmicPath = execSync('WHERE WMIC').toString().trim();
} catch (e) {
if (fs.existsSync(process.env.WINDIR + '\\system32\\wbem\\wmic.exe')) {
wmic = process.env.WINDIR + '\\system32\\wbem\\wmic.exe';
} else wmicPath = 'wmic';
wmicPath = process.env.WINDIR + '\\system32\\wbem\\wmic.exe';
if (!fs.existsSync(wmicPath)) {
try {
const wmicPathArray = execSync('WHERE WMIC').toString().split('\r\n');
if (wmicPathArray && wmicPathArray.length) {
wmicPath = wmicPathArray[0];
} else {
wmicPath = 'wmic';
}
} catch (e) {
wmicPath = 'wmic';
}
}
}
return wmicPath;