Cannot start sevice - "Access is denied"

Hello,
When deploying a service that does not already exist on the target host, I get this error -

============================
[SC] CreateService SUCCESS
Error 12:13:59
Start-Service : Service ‘SPIN.AMS (SPIN.AMS)’ cannot be started due to the
Error 12:13:59
following error: Cannot start service SPIN.AMS on computer ‘.’.
Error 12:13:59
At C:\Program Files\Octopus Deploy\Tentacle\Scripts\Octopus.Features.WindowsSer
Error 12:13:59
vice_BeforePostDeploy.ps1:138 char:2
Error 12:13:59

  • Start-Service $ServiceName
    Error 12:13:59

Error 12:13:59

  • CategoryInfo : OpenError: (System.ServiceProcess.ServiceControl
    Error 12:13:59
    ler:ServiceController) [Start-Service], ServiceCommandException
    Error 12:13:59
  • FullyQualifiedErrorId : CouldNotStartService,Microsoft.PowerShell.Comman
    Error 12:13:59
    ds.StartServiceCommand
    ===========================

If I logon to the host and try to manualy start the service, I get an “Access is denied” error and the service wont start.
If I manually delete and re-create the service with SC at the command line, the service then starts up ok.
Ive tried this on two different serves witht the same result.

So, this appears to be an issue with the permission granted to octopus when running the SC util?

Any ideas on how to resolve this?

Details:
Octopus Deploy - 2.5.11.614
Target host - Windows Server 2012

Thanks

Hi Aled,

Thanks for getting in touch! Generally when this occurs, the Service Name in Octopus does not match the Service Name the service is expecting.
Can you check that your settings in the Octopus step directly match the service name you are trying to create.

Thanks!
Vanessa

We are having exactly the same issue installing a windows service. If I don’t select the option to install the service (IE - I just replace the existing service using Octopus deploy) then everything works fine. I have checked the name against the display name and they are identical.

It looks like the issue is that when the service is installed, the ImagePath registry variable does not contain the full path of the service executable, it contains only the parent directory of the service executable. When I modify the ImagePath variable in the registry with the fully qualified name of the exe, including the exe name, then the service will start correctly.

Never mind. After posting, I realized that the “Executable path” in my process step was incomplete. Service creation works. Next - add MSMQ step.