Search code examples
pythonwindowssubprocessterminate

Terminate subprocess in Windows, access denied


-

import time
import subprocess
from os.path import expanduser

chrome_path = expanduser('~\Local Settings\Application Data\Google\Chrome\Application\chrome.exe')

proc = subprocess.Popen(chrome_path)
time.sleep(4)
proc.terminate()

Output: WindowsError: [Error 5] Access is denied

How can I kill the Chrome process?

Python 2.6 on Windows XP.


Solution

  • what happens if you use TASKKILL /F /PID [number of process ID] ? Give it a try. Launch it through import OS