JAVA 检测进程 检查进程

import javax.swing.JOptionPane;


public class ProcessChecking {
  
    private static int tasklist1 = -1;
    public int checkProcess(String progressName){
        try {

            String cmd = "cmd.exe /c  tasklist";
            Process p = Runtime.getRuntime().exec(cmd);
            StringBuffer out = new StringBuffer();
            byte[] b = new byte[1024];
            for (int n; (n = p.getInputStream().read(b)) != -1;) {
                out.append(new String(b, 0, n));
            }
            tasklist1 = out.toString().indexOf(progressName);// 检查QQ进程
        } catch (Exception e1) {
            e1.printStackTrace();
        }

 

 



        if (tasklist1 == -1) {

            //JOptionPane.showMessageDialog(null, "程序已经关闭!", "警告", 1);
            return 0;
        } else {
            //JOptionPane.showMessageDialog(null, "程序已经打开!", "警告", 1);
            return 1;
        }
       
    }
   
}

 

 

 

 

要做一个web 远程开软件关软件,那么要判断这个软件的进程是不是启动着,所有要进程判断下

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值