How to install a service on windows 7 without Visual Studio?

主宰稳场 提交于 2019-12-06 04:24:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!