Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(isProcessRunning("Taskmgr.exe")){
- // TODO code application logic here
- killProcess("Taskmgr.exe");
- }
- public static boolean isProcessRunning(String servicename) throws Exception {
- Process p = Runtime.getRuntime().exec(TASKLIST);
- BufferedReader reader = new BufferedReader(new InputStreamReader(
- p.getInputStream()));
- String line;
- while ((line = reader.readLine()) != null) {
- System.out.println(line);
- if (line.contains(servicename)) {
- System.err.println(line);
- return true;
- }
- }
- return false;
- }
- public static void killProcess(String serviceName) throws Exception {
- Runtime.getRuntime().exec(KILL + serviceName);
- }
Add Comment
Please, Sign In to add comment