“Access is denied” when trying to start service even when running Administrator/elevated

windows-8.1windows-service

I'm using sc start "MyService" from an elevated "Administrator: Command Prompt" but am getting the following error:

[SC] StartService FAILED 5:

Access is denied.

For completeness, the error when you try to run it from the GUI (services.msc) is:

Error 5: Access is denied

As it's a .NET service, it was installed using InstallUtil.exe (run as Administrator). The service is configured to run as NETWORK SERVICE but I have also tried it with LOCAL SERVICE.

Best Answer

This was due to the fact by default neither the NETWORK SERVICE or LOCAL SERVICE have permissions to read from the directory where my service executable resides. I needed to grant them read privileges on the folder (at the very least).