Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Terminating Process Error "Access Denied"

Terminating Process Error "Access Denied"

Scheduled Pinned Locked Moved C / C++ / MFC
c++jsonhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    ku19832001
    wrote on last edited by
    #1

    Hi all i have a code where i am starting the process from a windows service that i created. Now i want to terminate that process using some other application(MFC stand alone) application. But when ever i try to do that,it gives error 5 which documentation says is "Error Access Denied"......here r the codes that i m using for creating and stopping the process 1)Creating a process success = ::CreateProcess(temp,cmdstr,0,0,FALSE,CREATE_NEW_CONSOLE,0,0,&startupinfo,&procinfo); where temp and cmdstr are application path and command line argument that i pass 2) terminating process HANDLE hn = ::OpenProcess(PROCESS_ALL_ACCESS,false,id); if(hn != NULL) { ::TerminateProcess(hn,0); } now here OpenProcess API fails and gives error........id is the process id of the process i started using a service......please suggest me a way out of this. thanks kunal s patel

    D 1 Reply Last reply
    0
    • K ku19832001

      Hi all i have a code where i am starting the process from a windows service that i created. Now i want to terminate that process using some other application(MFC stand alone) application. But when ever i try to do that,it gives error 5 which documentation says is "Error Access Denied"......here r the codes that i m using for creating and stopping the process 1)Creating a process success = ::CreateProcess(temp,cmdstr,0,0,FALSE,CREATE_NEW_CONSOLE,0,0,&startupinfo,&procinfo); where temp and cmdstr are application path and command line argument that i pass 2) terminating process HANDLE hn = ::OpenProcess(PROCESS_ALL_ACCESS,false,id); if(hn != NULL) { ::TerminateProcess(hn,0); } now here OpenProcess API fails and gives error........id is the process id of the process i started using a service......please suggest me a way out of this. thanks kunal s patel

      D Offline
      D Offline
      dnuts69
      wrote on last edited by
      #2

      The MSDN documentation here suggests that if you are trying to do OpenProcess with all access, you need to enable SeDebugPrivilege privilege. This is because all PROCESS_ALL_ACCESS includes access like reading/writing the target process' address space which is a privilege normally reserved for debuggers. If all you are doing is terminating the process, you should specify the minimum amount of access required to do that.

      FTS Technology Solutions

      K 1 Reply Last reply
      0
      • D dnuts69

        The MSDN documentation here suggests that if you are trying to do OpenProcess with all access, you need to enable SeDebugPrivilege privilege. This is because all PROCESS_ALL_ACCESS includes access like reading/writing the target process' address space which is a privilege normally reserved for debuggers. If all you are doing is terminating the process, you should specify the minimum amount of access required to do that.

        FTS Technology Solutions

        K Offline
        K Offline
        ku19832001
        wrote on last edited by
        #3

        Considering wat u said i changed the PROCESS_ALL_ACCESS to PROCESS_TERMINATE and tried it but again it failed so now i guess only option left is setting SeDebugPrivilege....now i really dont have a clue how to do it....please suggest me a way out of it

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups