Update processes.js

increase windows services lookup time for single services
also fix incorrect started compare
This commit is contained in:
Simon Smith 2022-01-15 15:10:18 +00:00 committed by GitHub
parent acf1a89bf2
commit 7b8fa912f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -324,7 +324,16 @@ function services(srv, callback) {
}
if (_windows) {
try {
util.powerShell('Get-WmiObject Win32_Service | fl *').then((stdout, error) => {
let wincommand = "Get-WmiObject Win32_Service ";
if (srvs[0] !== '*') {
wincommand += '-Filter "';
for (let i = 0; i < srvs.length; i++) {
wincommand += `Name='${srvs[i]}' or `;
}
wincommand = `${wincommand.slice(0,-4)}"`;
}
wincommand += '| fl *';
util.powerShell(wincommand).then((stdout, error) => {
if (!error) {
let serviceSections = stdout.split(/\n\s*\n/);
for (let i = 0; i < serviceSections.length; i++) {
@ -338,7 +347,7 @@ function services(srv, callback) {
if (srvString === '*' || srvs.indexOf(srvName) >= 0 || srvs.indexOf(srvCaption) >= 0) {
result.push({
name: srvName,
running: (started === 'TRUE'),
running: (started.toLowerCase() === 'true'),
startmode: startMode,
pids: [pid],
cpu: 0,