Search code examples
node.jsnode-webkit

How to Know if an specific windows service is installed with Node js?


I'm new in Node JS.

I'm building an new desktop app with web-kit.

One of my requirements is verify if an determinate service is installed on Windows. How can I do that on Node js?

I know how to find the application at the process list with Node Js. But what I really need is whether it is installed, because it can be stopped, but installed.


Solution

  • This will get you an array of all installed services:

    var exec = require("child_process").exec;
    exec("sc query state= all", function(err, stdout) {
        var lines = stdout.toString().split("\r\n").filter(function (line) {
            return line.indexOf("SERVICE_NAME") !== -1;
        }).map(function (line) {
            return line.replace("SERVICE_NAME: ", "");
        });
        console.log(lines);
    });