替换Windows中可执行程序的策略 [英] Strategies For Replacing Program Executable in Windows

查看:136
本文介绍了替换Windows中可执行程序的策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows程序,需要从服务器自动更新自身.

I have a Windows program that needs to update itself from a server automatically.

它已经能够从服务器传输文件并在加载文件之前更新+验证DLL插件文件之类的东西.

It is already able to transfer files from the server and update + validate things like DLL plugin files before loading them.

但是,该程序也需要自我更新.可能有几种不同的方法可以完成,而我从各种在线游戏客户端看到的最明显的方法是创建一个自动修补程序",该程序可以下载并运行客户端可执行文件.这就引入了必须更新自动修补程序的问题,因此,如果有更优雅的解决方案,我想听听.

However, this program also needs to update itself. There are probably a few different ways this could be done, and the most obvious one I've seen from various online game clients is creating an "auto patcher" that downloads and then runs the client executable. That introduces the problem of having to update the autopatcher, so if there is a more elegant solution I'd like to hear about it.

我必须想象有一种方法可以下载将新的可执行文件作为临时文件,比如说"client.exe.tmp",然后启动一个单独的过程,等待原始的client.exe退出.然后重命名/复制新文件.

I have to imagine there is a way to download what will be the new executable file as a temporary file, let's say "client.exe.tmp" and then launch a separate process that waits for the original client.exe to exit and then renames/copies the new file over the top of it.

有人成功完成过这样的事情吗?您使用什么方法使它起作用?

Has anyone done this sort of thing before successfully and what method did you use to get it to work?

推荐答案

  1. 正在运行的exe下载新的exe,并将其放置在某个地方
  2. 正在运行的exe会将自己重命名为任何内容(例如.exe.tmp)
  3. 正在运行的exe会将下载的exe放在正在运行的exe所在的位置(名称与原始exe一样)
  4. 正在运行的exe会启动下载的exe
  5. 下载的exe检查.exe.tmp文件,如果找到该文件,则会将其删除并杀死旧的运行进程
  6. 完成

这篇关于替换Windows中可执行程序的策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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