问题
Install a windows service: there is a util with Visual Studio: InstallUtil.exe. If I have a service MyService.exe and want to install it on a windows 7 without Visual Studio on it, how can I install it?
回答1:
You can try NSSM (Non-Sucking Service Manager) for the times the "sc" doesn't work quite as expected. http://nssm.cc
I had an service I built in Go not too long ago that I could not get to run under "sc", nssm worked perfectly.
回答2:
One way is to use sc.exe, which is part of OS. Example:
sc create **ServiceName** start= auto binPath= "c:\mydir\myService.exe"
where binPath is exe file containing your service.
if you don't want start type = automatic then you can use net start and net stop command on command line of windows to start and stop service respectively.
回答3:
you can find installUtil.exe at "C:\Windows\Microsoft.NET\Framework\v2.0.50727", launch from CMD prompt, and add the path to your service
回答4:
Couldn't get NSSM to work on my W7. It always put its own path as the path to the program I put in the Path box. Had to go manual with the sc example above. That worked perfectly. To get a list of sc parameters, just execute sc. The two * preceeding the ServiceName will cause the ServiceName to appear at the top of the C:\Windows\System32\compmgmt.msc list. To remove a service, use sc delete ServiceName. You will have focus the list and use the Refresh menu item to see the change in compmgmt.msc.
来源:https://stackoverflow.com/questions/13847771/how-to-install-a-service-on-windows-7-without-visual-studio