I am trying to create a simple Windows Service. The User Account for the service is NetworkService
. Then I ran installUtil
from command prompt and I got this :
The Commit phase completed successfully.
The transacted install has completed.
which means the service got installed successfully. But when I try to run it from the Service applet
i get this error :
Windows cannot the CustomersService service on Local Computer. Error 5 : Access is denied.
I am using 64bit Windows 7.
I am not sure if you've already got this resolved though, the following helped me fix this on my system:
- Grant full permissions to the service registry key under
HKLM > System > Current Control Set > Services > <Service Name>
. (Grant full permissions to Network Service Built in account on the key) - Check the image path (apparently the output path of the exe under the
bin > Debug
. - Add and give full permissions to the Network Service account here too.
This should help!
I got an access denied error 5 when I tried to run a service under "LOCAL SERVICE" user, but under "LOCAL SYSTEM" the service did start. To run the service under "LOCAL SERVICE" I had to do the following:
- Service set to run under "LOCAL SERVICE"
- I gave permissions to the user "LOCAL SERVICE" for the folder where the executable of the service is located in. (Right mouse button om folder, properties, security, add user "LOCAL SERVICE" with as many rights as possible
- Start service now
You can use procmon.exe of SysInternals to monitor the ACCESS DENIED error. Filter on "File System Activity" for the process "services.exe". You will probably see the path of the executable of the service that needs to be started in the "Path" column when the error "Access Denied" error code 5 occures.
This worked for me
Go to the service in the service manager >> right click on that service and choose Properties >> Click the Log On tab >> choose the Local System account.
Then start the service.
Through which user account type are you trying to start/stop the service? Make sure the user has sufficient privileges to start/stop a service.
来源:https://stackoverflow.com/questions/3615367/windows-service-error-5-access-denied