在客户端计算机上替换现有的服务exe表单最新版本 [英] Replace the existing service exe form latest version on client machine

查看:90
本文介绍了在客户端计算机上替换现有的服务exe表单最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello先生,



我在客户端机器上运行服务,每当我们对服务器exe进行一些更改时,我们提供并手动更换它。

是否有可能在共享位置进行该服务检查,如果有最新版本可以自行停止并将exe替换为最新版本并自行启动。



我尝试了什么:



Hello Sir,

I have service running on clients machine , Whenever we made some changes in service exe the we provide the and replace it manually.
Is it is possible to that service check at share location if there are latest version available the stop it self and replace the exe to latest and start it self.

What I have tried:

i have create a separate thread form service which will stop  service and copy file but not able to start.

推荐答案

您必须有第二个可执行文件才能执行此操作。当代码运行时,.EXE无法替换自身,因为文件被锁定。



您的更新程序.EXE需要每隔一段时间运行一次,检查安装的服务版本与服务器上可用的版本相对应。如果有不同的版本,请获取新服务可执行文件,停止服务,替换.EXE并重新启动服务。



您的更新程序可能是从Windows计划任务启动的普通控制台应用程序,或者可以编写为自己的服务。
You have to have a second executable that does that. An .EXE cannot replace itself as the file is locked when the code is running.

Your "updater" .EXE would need to run every once in a while, check the installed version of the service against the one available on the server. If a different version is available, get the new service executable, stop the service, replace the .EXE and restart the service.

Your "updater" could either be a normal console app that's launched from Windows Scheduled Tasks or could be written as its own service.


脏技巧:Windows 允许重命名正在运行的可执行文件,请参阅这篇关于它的CodeProject文章:简单自动更新:让你的应用程序使用2行代码更新自己 [ ^ ]

不知道这是否适用于服务...
Dirty trick: Windows does allow a running executable to be renamed, see this CodeProject article about it: Simple Auto-Update: Let your application update itself using 2 lines of code[^]
Don't know if this will work for a service however ...


这篇关于在客户端计算机上替换现有的服务exe表单最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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