In general, we can use Python to execute Windows's cmd command, for example:
os.system('ipconfig')
but I find that tskill
can not be executed by Python, if I use:
os.system('tskill 8684')
to kill a process by its pid, Python will show cmd's error:
'tskill' is not recognized as an internal or external command, operable program or batch file.
but it work well if I use cmd to run the command.
As I know tskill.exe
is located in C:\Windows\System32, but this path is not in Python's environment variable. It is maybe the reason, but ipconfig.exe
is also in System32, it can be executed.
So why tskill
can not be executed by os.system or subprocess.Popen?