I'm trying to kill a process (zoom.exe) with psutil. However, I'm getting an error psutil.AccessDenied
. I have all the permissions to do it, and was already tested on another pc.
Code
def kill_process(PROCNAME):
for proc in psutil.process_iter():
if proc.name() == PROCNAME:
proc.kill()
print(f'{PROCNAME} was succesfully killed')
time.sleep(3)
Traceback
Traceback (most recent call last):
File "C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\psutil\_c
ret = self._cache[fun]
AttributeError: _cache
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\psutil\_p
return fun(self, *args, **kwargs)
File "C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\psutil\_c
return fun(self)
File "C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\psutil\_p
exe = cext.proc_exe(self.pid)
PermissionError: [WinError 24] The program issued a command but the command length is incorrect.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:/Users/Acer/Desktop/autozoom/autozoom.py", line 211, in <module>
kill_process('Zoom.exe')
File "c:/Users/Acer/Desktop/autozoom/autozoom.py", line 25, in kill_process
if proc.name() == PROCNAME:
File "C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\psutil\__init__.py", line 630, in name
name = self._proc.name()
File "C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\psutil\_pswindows.py", line 750, in name
return os.path.basename(self.exe())
File "C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\psutil\_pswindows.py", line 681, in wrapper
raise convert_oserror(err, pid=self.pid, name=self._name)
psutil.AccessDenied: psutil.AccessDenied (pid=7868)