I\'m getting this error when I try to start a windows service I\'ve created in C#:
My Code
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.
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.
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.
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.
check windows event log for detailed error message. I resolved the same after checking event log.
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.