New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/sys/windows/svc: Failed to start windows service with Start Parameters #48227
Comments
I wasn't sure what that GUI field means, but found this answer: https://stackoverflow.com/a/42821528 |
@mshamn6x I don't know how to use I googled for it, and that is all I can find https://forums.codeguru.com/showthread.php?251755-Passing-Parameters-to-Win32-Services Also I would just use fields set in
This refers to a C# solution. So I don't see how that is helpful. Unless you can find translation of that C# code into Win32 API. Alex |
@Ale thanks for the reply. In registry by default command line argument is added properly in ImagePath field. As described in here, https://serverfault.com/a/143384/794689 Actually I followed all the mentioned methods in that thread. But none of them worked for me. I even tried following but none of them working as expected.
Do you want me to add SERVICE_ACCEPT_PARAMCHANGE and SERVICE_CONTROL_PARAMCHANGE parameters like this ? Do I need to change anything in this method https://github.com/golang/sys/blob/master/windows/svc/example/service.go#L23 ? |
No. I don't.
Why would I need you to change anything in that file? Alex |
No not exactly that file, I'm asking do I need to modify this function in my source, to pass those arguments or something like that? |
I do not know answer to your question. Alex |
Tried with following go version facing the same probelm.
|
If you call |
@zx2c4 Thank you for your reply on this. startService() has only one argument right ? That is to pass service name to s.Start(). If you meant s.Start() then i'm fine with it. Can you please kindly have look at this? I've created small code sample https://github.com/mshamn6x/go-windows-service here I've created simple command line argument with service. Let's say If I run "exmaple.exe init" it will write some log. And I tried to create windows service with this "init" parameter so whenever I starting this service it supposed to call this "init" argument , so that I expect log file should be updated, but it is not happening with this window service. Please provide your comments on this. |
https://pkg.go.dev/golang.org/x/sys/windows/svc/mgr#Service.Start Service.Start takes a variadic argument. |
yes, https://pkg.go.dev/golang.org/x/sys/windows/svc/mgr#Mgr.CreateService
I think in that source I used init parameters in both places |
I'm lost as to what the bug is that this issue is about. As far as I can tell, everything is working as expected? If so I believe you can close this? Or is there a subtlety I'm missing? |
No issue is not yet resolved. https://github.com/mshamn6x/go-windows-service have you checked this repo ? Steps to reproduce: _```
|
I don't recognize a Go bug in that description. Seems like there's some confusion over log files vs event log or something now, but I'm still unclear on what the issue here, and unfortunately I don't think I'll be able to help more. |
I want to create go executable that is command line argument style. I need to support the same in windows. So I need to create windows service right? I started work with this package and I was able to deploy service and start stop are working without any issue. But this webservice start stop are not working properly. If run manually webservice.exe start from command line then webservice is running. It should be like when I hit service start from services.exe I expect webservice should start properly. But with this windows service it is not working properly. Can anyone add example with start parameter? |
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried creating windows service for windows console application that runs webservice. Followed example from https://github.com/golang/sys/tree/master/windows/svc/example
Based on above example I'm able to install windows service using go. But when I try to start it with start parameter it is not working in expected way. I used following configuration for created windows service,
I assume command line argument(start parameter) Added properly in service (init command appears with executable path so...), refer below image.
I programmed like whenever init is executed with that application, log will be written in log file. If I run that manually logs are properly updated. But with this windows service it is not working properly. Likewise I want to create webservice start/stop through windows service.
In above image "start parameter" field is also empty. Whether this is correct way of doing it ? If not please share examples.
What did you expect to see?
windows service with Start parameter would work properly.
What did you see instead?
Windows service with start parameter is not working properly.
The text was updated successfully, but these errors were encountered: