title: Python - psutil Windows permission error?
body: <p>I'm attempting to get the PID of a process on Windows 7 using psutil, but I'm running into a permissions error. I've tried running the Command Prompt which is running the script as administrator, but this doesn't seem to have any effect. Both the error and the relevant code is below. The line that the error occurs on is when trying to access the process name using <code>proc.name</code>. Any suggestions on how I might fix this? Thank you much!</p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Python33\lib\site-packages\psutil\_psmswindows.py", line 190, in wrapper
      return fun(self, *args, **kwargs)
    File "C:\Python33\lib\site-packages\psutil\_psmswindows.py", line 229, in get_process_exe
      return _convert_raw_path(_psutil_mswindows.get_process_exe(self.pid))
  PermissionError: [WinError 5] Access is denied
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "simple_address_retrieve.py", line 14, in &lt;module&gt;
      if proc.name == PROCNAME:
    File "C:\Python33\lib\site-packages\psutil\_common.py", line 48, in __get__
      ret = self.func(instance)
    File "C:\Python33\lib\site-packages\psutil\__init__.py", line 341, in name
      name = self._platform_impl.get_process_name()
    File "C:\Python33\lib\site-packages\psutil\_psmswindows.py", line 190, in wrapper
      return fun(self, *args, **kwargs)
    File "C:\Python33\lib\site-packages\psutil\_psmswindows.py", line 222, in get_process_name
      return os.path.basename(self.get_process_exe())
    File "C:\Python33\lib\site-packages\psutil\_psmswindows.py", line 194, in wrapper
      raise AccessDenied(self.pid, self._process_name)
  psutil._error.AccessDenied: (pid=128)
  </code></pre>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>PROCNAME = "MyProcessName.exe"
  
  for proc in psutil.process_iter():
      if proc.name == PROCNAME:
          print(proc)
  </code></pre>