我正在使用psutil
列出正在运行的进程。我想检查一些作为Windows服务运行的进程。该服务以SYSTEM
用户的身份运行,Windows不允许IIS用户查看有关该过程的信息。
例如
>>> import psutil
>>> p = list(psutil.process_iter())[0]
>>> print p.username()
'NT AUTHORITY\\SYSTEM'
>>> print p.cmdline()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\psutil\__init__.py", line 666, in cmdline
return self._proc.cmdline()
File "C:\Python27\lib\site-packages\psutil\_pswindows.py", line 638, in wrapper
raise AccessDenied(self.pid, self._name)
psutil._exceptions.AccessDenied: psutil.AccessDenied