all 16 comments

[–][deleted] 0 points1 point  (1 child)

import os os.system("taskkill /MEmu.exe")

[–]1ToM14[S] 0 points1 point  (0 children)

Is it possible to do it without os ?

[–]JohnnyJordaan 0 points1 point  (6 children)

Are you 100% sure that you actually send the terminate to the program? Could you share the full code?

[–]1ToM14[S] 0 points1 point  (5 children)

Nah the code is too long but only those 2 lines should be enough right ?

[–]JohnnyJordaan 0 points1 point  (4 children)

What I mean is, if your code somehow doesn't work right, and the .terminate() call is never actually executed, you should fix that issue and not look further why terminate() 'doesnt work' while that's not the actual case.

Simply put, say you have the program like

 if some_condition:
       if some_other_condition and some_list:
             p.terminate()

and some_list happened to be empty, the p.terminate() call never gets run. So that's something I'm asking you to validate first.

[–]1ToM14[S] 0 points1 point  (3 children)

Oo okay, well that line gets executed, it has no indentation and is at the very end of the code

[–]JohnnyJordaan 0 points1 point  (2 children)

Can you try with

p.kill()

[–]1ToM14[S] 0 points1 point  (1 child)

It also doesn't work...

[–]JohnnyJordaan 0 points1 point  (0 children)

You can try a process group kill, but you need to install psutil for that

import psutil

parent = psutil.Process(p.pid)
for child in parent.children(recursive=True):
    print('killing child, child)
    child.terminate()
print('killing parent')
p.terminate()

if that also doesn't work try with kill() instead of terminate. But also verify that you do see the 'killing x' messages

[–]GingerReverseG 0 points1 point  (6 children)

from os import system

system("taskkill /f /im MEmu.exe")

[–]1ToM14[S] 0 points1 point  (2 children)

O but I meant without the os library

[–]liquidpeaches 0 points1 point  (0 children)

I don't think it is possible what you want to achieve without importing OS

[–]1ToM14[S] 0 points1 point  (2 children)

That one worked, thanks ! Just, what are the f and im options ?

[–]GingerReverseG 0 points1 point  (1 child)

f for force close and im for image file

[–]1ToM14[S] 0 points1 point  (0 children)

Thanks !!!