Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List running applications using NodeJS

Tags:

node.js

Using NodeJS I want to get a list of open applications on Windows.

Something along the lines of:

exec("tasklist", function (error, stdout, stderr) {

    for(var i=0;i<stdout.length;i++)
    {
        if( stdout[i]['name'].indexOf('ll_') > -1 )
        {
            appList.push({'id':stdout[i]['id'],'name':stdout[i]['name']});
        }
    }

});

Where appList is an object of running applications with their ID and Name if they start with ll_.

How can I do this?

like image 836
Cameron Avatar asked Jun 16 '15 09:06

Cameron


People also ask

How do I know if node JS is running?

In windows you can simply go to the Task Manager and check for node in the application list. If it is there then it is running in the machine. There is no default page or URL that node server provides from which you can know that node is running on that server by using the Public IP address or domain name.

What does nodeJS run on?

Node. js runs on chrome v8 engine which converts javascript code into machine code, it is highly scalable, lightweight, fast, and data-intensive. Working of Node.


1 Answers

(I don't run Windows, so the following is untested)

First, install tasklist:

$ npm install tasklist

Then, use the following script:

var tasklist = require('tasklist');

tasklist(function(err, tasks) {
  if (err) throw err; // TODO: proper error handling
  var appList = tasks.filter(function(task) {
    return task.imageName.indexOf('ll_') === 0;
  }).map(function(task) {
    return {
      id   : task.pid, // XXX: is that the same as your `id`?
      name : task.imageName,
    };
  });
});
like image 51
robertklep Avatar answered Sep 28 '22 06:09

robertklep