I'm trying to kill an .exe with subprocess.Popen.
Solution as:
- taskkill /im (.exe) /t /f
- taskkill /pid (.exe) /t /f
aren't working as the response is access denied. Indeed, as i'm running the cmd from subprocess i'm not able to obtain admin privilegies.
I've found a command to kill this process from cmd (without running it as admin) which is:
- wmic process where name=".exe" delete
... but when i'm running it with subprocess it gives me "invalid query". The command i'm running is:
4)subprocess.Popen(['wmic', 'process', 'where', 'name="-------.exe"', 'delete'], shell=True, stdout=subprocess.PIPE)
I suppose that i'm writing it wrongly. Some advices?
['cmd', '/c', 'wmic process where name="openvpn.exe" delete']
or maybe just pass the whole thing as string:subprocess.popen('wmic process where name="openvpn.exe" delete')
- CherryDTshell=True
; it sometimes happens to work in weird ways, but is basically always an error. See also stackoverflow.com/questions/3172470/… - tripleee