"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:
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.