From bd842b20a4efb16f27a02a56ddde666395d126f9 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Wed, 29 May 2019 19:50:45 +0200 Subject: [PATCH] wmic path fix - windows --- CHANGELOG.md | 2 ++ docs/history.html | 5 +++++ docs/index.html | 2 +- lib/util.js | 18 ++++++++++++------ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aac180d..0b43ea5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,8 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.6.1 | 2019-05-29 | get wmic path - fic windows | +| 4.6.0 | 2019-05-27 | added `dockerInfo()` | | 4.5.1 | 2019-05-17 | updated docs | | 4.5.0 | 2019-05-17 | `fsOpenFiles()` added open file descriptor count | | 4.4.1 | 2019-05-11 | updated docs | diff --git a/docs/history.html b/docs/history.html index 7ef393e..ed60e47 100644 --- a/docs/history.html +++ b/docs/history.html @@ -80,6 +80,11 @@ + + 4.6.1 + 2019-05-29 + wmic path fix - windows + 4.6.0 2019-05-27 diff --git a/docs/index.html b/docs/index.html index 2a794df..5a72a68 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
-
Current Version: 4.6.0
+
Current Version: 4.6.1
diff --git a/lib/util.js b/lib/util.js index e2eb156..c7a117b 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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;