System error 5 Access is denied when starting a .NET service

Daniel O picture Daniel O · Feb 22, 2009 · Viewed 69.7k times · Source

When I try to start a service I created in Visual Studio I receive the following error:

System error 5 has occurred.

Access is denied.

I am running the command line with elevated privileges, so it's not that problem. Is there any place I can look to see what error is occuring.

Answer

Daniel O picture Daniel O · Feb 22, 2009

To get it to work I needed to add permissions to the output bin\debug folder for my service project.

The Local Service account didn't have permissions to the output .exe file, and this was why the error was occuring.