Error 5 : Access Denied when starting windows service

前端 未结 30 2366
滥情空心
滥情空心 2020-12-04 18:49

I\'m getting this error when I try to start a windows service I\'ve created in C#:

\"alt

My Code

相关标签:
30条回答
  • 2020-12-04 19:10

    As the error popup suggests this is related to permission. So run the service as "LocalSystem" account.

    To do the same, Right Click on serviceProcessInstaller -> Properties -> Account and set it to "LocalSystem" instead of the default "User". Install the service and voila.

    0 讨论(0)
  • 2020-12-04 19:10

    I had this issue on a service that I was deploying, and none of the other suggestions on this question worked. In my case, it was because my .config (xml) wasn't valid. I made a copy and paste error when copying from qualif to prod.

    0 讨论(0)
  • 2020-12-04 19:14

    Computer -> Manage -> Service -> [your service] properties. Then the the tab with the account information. Play with those settings, like run the service with administrator account or so.

    That did it for me.

    EDIT: What also can be the problem is that, most services are run as LOCAL SERVICE or LOCAL SYSTEM accounts. Now when you run C:/my-admin-dir/service.exe with those accounts but they are not allowed to execute anything in that directory, you will get error 5. So locate the executable of the service, RMB the directory -> Properties -> Security and make sure that the account the service is run with, is in the list of users that are alloewd to have full control over the directory.

    0 讨论(0)
  • 2020-12-04 19:14

    In my case I kept the project on desktop and to access the desktop we need to add permission to the folder so I simply moved my project folder to C:\ directory now its working like a charm.

    0 讨论(0)
  • 2020-12-04 19:14

    check windows event log for detailed error message. I resolved the same after checking event log.

    0 讨论(0)
  • 2020-12-04 19:16

    Have a look at Process Utilities > Process monitor from http://www.sysinternals.com.

    This is tool that allows you monitor what a process does. If you monitor this service process, you should see an access denied somewhere, and on what resource the access denied is given.

    0 讨论(0)
提交回复
热议问题