如何更新已安装的Windows服务? [英] How to update an installed Windows service?

查看:307
本文介绍了如何更新已安装的Windows服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用C#编写了Windows服务.

I have written a Windows service in C#.

此后,我将其安装在我的计算机上,并且运行正常.

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

安装服务时,exe是否会复制到某处?还是指向我的bin文件夹?

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?

推荐答案

如果Windows服务的位置未更改,并且其可执行文件的名称也未更改,则不必卸载并重新安装它.您可以简单地使用net stop停止服务,使用新版本更新其可执行文件,然后使用net start重新启动它.这种方法对我来说可靠地工作了很多个月.

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 with net stop, update its executable with a new version, and start it again with net start. This approach worked reliably for me for many months.

如果要自动更新服务,则可以使用Google Omaha之类的框架.这是Google用来更新Chrome的技术.它与服务一起很好地工作,因为它像服务一样在后台静默运行. 本文提供了有关使用奥马哈的更多信息自动更新服务.

If you want to update your Service automatically, you can use a framework such as Google Omaha. This is the technology which Google use to update Chrome. It works well with Services because it runs silently in the background, just like a Service. This article gives more information about using Omaha to auto-update a Service.

这篇关于如何更新已安装的Windows服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆