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 远程开软件关软件,那么要判断这个软件的进程是不是启动着,所有要进程判断下