You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Commands run:
"go run main.go install" This command worked, it installed the service
"go run main.go start" This command failed with "failed to start myservice: could not start service: The system cannot find the file specified"
What did you expect to see?
I expected the service to actually work, and show in the services menu.
What did you see instead?
"failed to start myservice: could not start service: The system cannot find the file specified"
The text was updated successfully, but these errors were encountered:
mdlayher
changed the title
Example does not work.
x/sys/windows/svc: example service fails to start
Nov 13, 2020
And that API requires you to provide full path to your service executable (see lpBinaryPathName parameter). And, once installed, the service executable cannot be moved (until service is deleted), because Windows will try to run it when you request Windows to start your service.
When you use go run ... command, your executable is built inside of TEMP directory, executed and gets deleted immediately. So when you run go run main.go start your service executable is gone. That is why Windows is complaining.
Do not use go run ... command with this example. Build executable instead. Copy built executable to a location where it could remain until you remove your service.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I ran the example as built via the terminal, example can be found here: https://github.com/golang/sys/tree/0a15ea8d9b02651b828a1b41989a6af25c24cb64/windows/svc/example
Commands run:
"go run main.go install" This command worked, it installed the service
"go run main.go start" This command failed with "failed to start myservice: could not start service: The system cannot find the file specified"
What did you expect to see?
I expected the service to actually work, and show in the services menu.
What did you see instead?
"failed to start myservice: could not start service: The system cannot find the file specified"
The text was updated successfully, but these errors were encountered: