JF Fortier Posted January 9, 2021 Posted January 9, 2021 (edited) Hi, Going to FM19, I'm updating some old plugin and I need to know if an application is running or not on the client PC. I used Moo Plug for years and it work https://mooplug.com/docs/functions/moo_processrunning ** Edit: A new x64 version is on the way, Adam send me a beta version ** I'm trying this code try { String line; Process p = Runtime.getRuntime().exec (System.getenv("windir") +"\\system32\\"+"tasklist.exe"); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) { System.out.println(line); //<-- Parse data here. } input.close(); } catch (Exception err) { err.printStackTrace(); } I know nothing about Java or Groovy, but it look like it's sending data in the "while" one by one and at the end the input.close flush the result and I get nothing ?!?! So from the return value I could test if my process is running or not. If someone could shed some light, it will be appreciated. Thanks Edited January 10, 2021 by JF Fortier
JF Fortier Posted January 10, 2021 Author Posted January 10, 2021 (edited) By reversing engineering many script and code on the web, I wrote the script like this and it return what I need to have, so for anyone looking to get the list of all running process on windows, use it freely 😁 TaskList = '' Process p = Runtime.getRuntime().exec (System.getenv("windir") +"\\system32\\"+"tasklist.exe /nh " ) BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) { TaskList = TaskList + line + '\n' } return TaskList Edited January 10, 2021 by JF Fortier
JF Fortier Posted January 10, 2021 Author Posted January 10, 2021 (edited) Using this will only bring the process name in a list, no more useless data TaskList = '' Process p = Runtime.getRuntime().exec (System.getenv('windir') +'\\system32\\' + 'tasklist.exe /nh /fo csv' ) BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) { line = Eval.me('[' + line + ']') TaskList += line.get(0) + '\n' } return TaskList Edited January 10, 2021 by JF Fortier
Recommended Posts
This topic is 1411 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now