From 7dd89dae09abe1a158c542d38f0186b8f8c4dfef Mon Sep 17 00:00:00 2001 From: missingtears Date: Sat, 11 Apr 2020 12:37:50 +0800 Subject: [PATCH 1/2] Update index.js Environment variables not find WMIC in windows 7 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 10edd32..72bde93 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,7 @@ module.exports = function childrenOfPid(pid, callback) { var processLister; if (process.platform === 'win32') { // See also: https://github.com/nodejs/node-v0.x-archive/issues/2318 - processLister = spawn('wmic.exe', ['PROCESS', 'GET', 'Name,ProcessId,ParentProcessId,Status']); + processLister = spawn(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, ['PROCESS', 'GET', 'Name,ProcessId,ParentProcessId,Status']); } else { processLister = spawn('ps', ['-A', '-o', 'ppid,pid,stat,comm']); } From 454a8ded3cddc1c8024056049fbfef6fa1bee9bc Mon Sep 17 00:00:00 2001 From: missingtears Date: Fri, 17 Apr 2020 22:49:48 +0800 Subject: [PATCH 2/2] Update index.js Environment variables not find WMIC in windows 7 --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 72bde93..94c1a83 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ 'use strict'; var spawn = require('child_process').spawn, + path = require('path'), es = require('event-stream'); module.exports = function childrenOfPid(pid, callback) { @@ -48,7 +49,7 @@ module.exports = function childrenOfPid(pid, callback) { var processLister; if (process.platform === 'win32') { // See also: https://github.com/nodejs/node-v0.x-archive/issues/2318 - processLister = spawn(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, ['PROCESS', 'GET', 'Name,ProcessId,ParentProcessId,Status']); + processLister = spawn(path.join(process.env.SystemRoot, 'System32\\wbem\\WMIC.exe'), ['PROCESS', 'GET', 'Name,ProcessId,ParentProcessId,Status']); } else { processLister = spawn('ps', ['-A', '-o', 'ppid,pid,stat,comm']); }