title: Getting 'psutil.AccessDenied (pid=6836)' error using psutil
body: <p>I want to check if a program is running or not, so I searched and I tried <a href="https://stackoverflow.com/a/7788702/13518924">this</a> , in this way:</p>
  
  <pre><code>import psutil
  if "notepad.exe" in (p.name() for p in psutil.process_iter()):
      print('program is running')
  else:
      print('not running')
  </code></pre>
  
  <p>but I get this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "~/temp.py", line 2, in &lt;module&gt;
      if "notepad.exe" in (p.name() for p in psutil.process_iter()):
    File "~/temp.py", line 2, in &lt;genexpr&gt;
      if "notepad.exe" in (p.name() for p in psutil.process_iter()):
    File "~\Python\Python38-32\lib\site-packages\psutil\__init__.py", line 630, in name
      name = self._proc.name()
    File "~\Python\Python38-32\lib\site-packages\psutil\_pswindows.py", line 750, in name
      return os.path.basename(self.exe())
    File "~\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=6836)
  
  Process finished with exit code 1
  </code></pre>
  
  <p>am I doing something wrong with this simple code?
  or is there another alternative way? </p>
  
  <p>EDIT: sorry, i forgot to mention im on windows, not linux,  can u give me solutions for windows platform?</p>