使用 NodeJS 我想获取 Windows 上打开的应用程序列表。
类似的东西:
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']});
}
}
});
Run Code Online (Sandbox Code Playgroud)
如果appList应用程序的 ID 和名称以ll_.
我怎样才能做到这一点?
(我不运行 Windows,所以以下未经测试)
首先,安装tasklist:
$ npm install tasklist
Run Code Online (Sandbox Code Playgroud)
然后,使用以下脚本:
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,
};
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4715 次 |
| 最近记录: |