Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Service : error 5 :Access Denied

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.

like image 242
TCM Avatar asked Sep 01 '10 05:09

TCM


3 Answers

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!

like image 160
Vaibhav Singh Avatar answered Oct 06 '22 01:10

Vaibhav Singh


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.

like image 21
Mike de Klerk Avatar answered Oct 06 '22 02:10

Mike de Klerk


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.

like image 44
Alexander Zaldostanov Avatar answered Oct 06 '22 02:10

Alexander Zaldostanov