title: Access Denied Python Script Pstuil
body: <p>So basically I have Created this application in python that uses Psutil. Iam using it to suspend and resume a process at very high speeds. Although it does work for the majority of the process it doesn't work for some. Ill provide the error code down below but if you do decide to help please be very noob friendly Iam just getting started in python</p>
  
  <pre><code>import psutil
  import time
  import subprocess
  
  
  
  print("Auto Suspender")
  
  condition = 10
  
  subprocess.call("taskkill /Program example")
  
  print("Program Example has been killed :)")
  
  time.sleep(1)
  
  somepid = int(input("What is Process ID ?"))
  p = psutil.Process(somepid)
  print("Working...")
  time.sleep(0.5)
  
  while condition == 10:
      choice = input("1__Suspend")
      if (choice == "1"):
          while condition == 10:
              p.suspend()
              print("Suspended !")
              time.sleep(0.1)
              p.resume
              print("Resumed !")
      else:
          print("Invalid response")`enter code here`
  </code></pre>
  
  <p>ERROR Iam getting </p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Python34\lib\site-packages\psutil\_pswindows.py", line 207, in wrapper
      return fun(self, *args, **kwargs)
    File "C:\Python34\lib\site-packages\psutil\_pswindows.py", line 366, in suspend
      return cext.proc_suspend(self.pid)
  PermissionError: [WinError 5] Access is denied
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "C:/Users/Jacob/PycharmProjects/Suspender.111/Main.py", line 26, in &lt;module&gt;
      p.suspend()
    File "C:\Python34\lib\site-packages\psutil\__init__.py", line 273, in wrapper
      return fun(self, *args, **kwargs)
    File "C:\Python34\lib\site-packages\psutil\__init__.py", line 1025, in suspend
      self._proc.suspend()
    File "C:\Python34\lib\site-packages\psutil\_pswindows.py", line 213, in wrapper
      raise AccessDenied(self.pid, self._name)
  psutil.AccessDenied: (pid=3076)
  
  Process finished with exit code 1
  </code></pre>