How to conditionally use subprocess.call("taskkill /f /im java.exe")
You can use subprocess.call to run tasklist or wmic process get description first to get a full list of running processes and see if java.exe is among them.
In my python code, I need to kill any java.exe subprocess, I am using subprocess.call("taskkill /f /im java.exe"), this is working fine when java.exe subprocess exists but it failed with "ERROR: The process "java.exe" not found" if java.exe subprocess does not exist, so I want to know if there is any way to detect if any java.exe subprocess is running and then try to kill it.