Skip to content Skip to sidebar Skip to footer

How Can I Kill The Explorer.exe Process?

I'm writing a script which is meant to kill explorer.exe. I searched a bit about it and the best answer I've seen uses the taskkill command. I tried it, but when I run it on my com

Solution 1:

I suggest using os.kill() instead. It is much clearer and returns a clearer value. You can do something like this:

import wmi

for process in wim.WMI().Win32_Process ():
    if process.Name == 'explorer.exe':
        os.kill(process.ProcessId)

Note that it matters which version of Python you're running (https://docs.python.org/2/faq/windows.html#how-do-i-emulate-os-kill-in-windows)


Solution 2:

I was running into this same issue, where I need to kill the explorer.exe process. Apparently you ahve to forcibly kill the process with a /F flag.

os.system("taskkill /im explorer.exe /F")


Post a Comment for "How Can I Kill The Explorer.exe Process?"