How to update an installed Windows service?

坚强是说给别人听的谎言 提交于 2019-12-03 10:50:20

问题


I have written a Windows service in C#.

I have since installed it on my machine, and it runs just fine.

When you install a service, does the exe get copied somewhere? Or does it point to my bin folder?

This is for me to know that when I update my code from time to time, do I have to uninstall and re-install my service to update it?


回答1:


If the Windows service's location has not changed and the name of its executable has not changed, you should not have to uninstall and reinstall it.

You can simply stop the service, update its executable with a new version, and start it again.

This approach worked reliably for me for many months of Windows-services development during which I simply updated services' ServiceBase implementations, private methods etcetera; and it makes for pretty quick iterative development when you have net stop and net start commands for your service(s) in a command window's history to just Alt+Tab over, backtrack through history, and hit Enter when you find the command you need.




回答2:


You can check the path of installed service by opening services.msc from Run. Then right click your service and see the 'Path to executable'.

If this points to your bin directory, then it will be updated every time you compile successfully.




回答3:


You should uninstall the old windows service and install new version of windows service.

uninstall:

   installutil /u yourproject.exe

install:

   installutil yourproject.exe


来源:https://stackoverflow.com/questions/22162477/how-to-update-an-installed-windows-service

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