Go version
go version go1.24.5 windows/amd64
Output of go env
in your module/workspace:
set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=0
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
What did you do?
It is not possible to create a boot service using the svc package because there is code that changes the boot start type to manual:
https://cs.opensource.google/go/x/sys/+/refs/tags/v0.34.0:windows/svc/mgr/mgr.go;l=119
What did you see happen?
The boot services I am creating are instead marked as manual start type.
What did you expect to see?
I expected the library to pass along the start type value of 0 to system call that creates the service.
as documented in the windows pkg here:
https://cs.opensource.google/go/x/sys/+/refs/tags/v0.34.0:windows/service.go;l=31
And Microsoft documentation here:
https://learn.microsoft.com/en-us/dotnet/api/system.serviceprocess.servicestartmode?view=net-9.0-pp
0 is a valid start type which indicates a boot time service.
In case this comes up: Even if golang or the svc package does not support boot-time windows services, that is irrelevant because golang code can be used to manage arbitrary services using this package.
I am having to rewrite code and do direct system calls because it's either that or use os.exec to run OS commands which I'm trying to avoid doing.
Comment From: gabyhelp
Related Issues
- x/sys/windows/svc/mgr: CreateService does not allow driver loading #14019 (closed)
- x/sys/windows/svc: Failed to start windows service with Start Parameters #48227
- x/sys/windows/svc/example: does not start #40160 (closed)
- x/sys/windows/svc: example service fails to start #42596 (closed)
- x/sys/windows/svc: Error 1053 could not start service when user assigned is not Local System Account or has no admin rights #45966 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)