I am writing a small Python script for Windows that runs a certain program using subprocess.Popen and then, after a while, kills it. I could use Popen.terminate or Popen.kill to terminate that program, however, as indicated by the docs, those would act the same by calling the Windows API function TerminateProcess. However, that function terminates the program immediately, which may result in errors. I would like to replicate the result of hitting the 'X' button, which uses the 'ExitProcess' function. Is that possible?
Asked
Active
Viewed 14 times
0
One Nose
- 42
- 5
-
Are you looking for [this](https://stackoverflow.com/a/2581943/13629335) – Thingamabobs Jun 03 '22 at 11:16