I was supposed to convert a GoLang compiled file .exe as a service in windows but as the service was executed with 9 parameters from outside so I decided to use SC to make the .exe as a service and my syntax was ,
sc create myservice binPath= "\"PATH\file.exe\" -param1=value -param2=value -param3=value...-param9=value" displayname= "MyServer" start= auto
the service created successfully but when I try to start it, it fails with "service did not respond in a timely fashion" ..
But When I created the same service with nssm syntax ,
nssm install myservice "PATH\file.exe" -param1=value -param2=value -param3=value...-param9=value
It was working and I was getting response from my service , I don't know whether the problem is with the syntax in SC or my service...
I even tried many possible ways like removing \" and giving parameters directly like binPath= "PATH/file.exe -param1=value -param2=value...param9=value"
but it didn't work and I also tried to pass the parameters inside quotes , It didn't work either :( Any help would be appreciated.
Run
function from thegolang.org/x/sys/windows/svc
package. Perhaps your main function is exiting without ever callingRun
because it doesn't like the parameters it was given?sc
works for your other executables, so those executables must be using the svc package or some equivalent. You cannot use sc directly on an executable that was not built to be a service. This doesn't work, ever. (Of course, you can usesc
indirectly, by pointing it atsrvany.exe
ornssm.exe
or equivalent.)