使用 Java 的 Windows 运行应用程序列表 [英] Windows running application list using Java

查看:44
本文介绍了使用 Java 的 Windows 运行应用程序列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Java获取Windows正在运行的应用程序列表?我必须获取进程列表.

How to get Windows running application list using Java?I got to get the processlist.

推荐答案

我也建议使用 qprocess 实用程序,然后,如果您需要有关进程的更多信息,请使用 wmic.

I would recommend also using the qprocess utility, then, if you need more info about a process, use wmic.

示例:

String line;
try {
        Process proc = Runtime.getRuntime().exec("wmic.exe");
        BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
        OutputStreamWriter oStream = new OutputStreamWriter(proc.getOutputStream());
        oStream .write("process where name='explorer.exe'");
        oStream .flush();
        oStream .close();
        while ((line = input.readLine()) != null) {
            System.out.println(line);
        }
        input.close();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

参见 http://ss64.com/nt/wmic.htmlhttp://support.microsoft.com/servicedesks/webcasts/wc072402/listofsampleusage.asp 一些你可以从 wmic 得到什么的例子......

See http://ss64.com/nt/wmic.html or http://support.microsoft.com/servicedesks/webcasts/wc072402/listofsampleusage.asp for some example of what you can get from wmic...

这篇关于使用 Java 的 Windows 运行应用程序列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆