Windows 7自我/自动更新可执行文件

时间:2021-08-22 02:07:38

I've had a custom auto-update feature for my programs ever since Windows 95. It used to work fine, until Vista and then Windows 7. What it basically did was to download the new executable, create a batch file and execute it. The batch file simply waited for parent executable to close (by constantly trying to delete it) and then move/rename the downloaded new one as the old one. And even run the newly downloaded one. This worked fine for years. But Windows 7 doesn't really like me to do that. One thing is that it "knows" the executables are no longer same (even though their names and paths are same).

自从Windows 95以来,我已经为我的程序提供了自定义自动更新功能。它曾经工作正常,直到Vista和Windows 7.它基本上做的是下载新的可执行文件,创建一个批处理文件并执行它。批处理文件只是等待父可执行文件关闭(通过不断尝试删除它),然后将下载的新文件移动/重命名为旧文件。甚至运行新下载的。这项工作多年来一直很好。但Windows 7并不是真的喜欢我这样做。有一点是它“知道”可执行文件不再相同(即使它们的名称和路径相同)。

Is there a way to silently replace an executable with a new one by copying the executable properties/permission to the new one, so that Windows 7 won't complaint about it being a different exe? (Of course I need this for auto-update feature, so I'm open to other approaches as well)

有没有办法通过将可执行属性/权限复制到新的可执行属性/权限来静默替换可执行文件,以便Windows 7不会抱怨它是一个不同的exe? (当然我需要这个用于自动更新功能,所以我也对其他方法持开放态度)

2 个解决方案

#1


0  

Hmm ClickOnce w/ .NET works great for this... Don't know what you mean by windows 7 complaining about the exe however.

嗯ClickOnce w / .NET非常适合这个...不知道你的意思是Windows 7抱怨exe。

#2


0  

Not sure about the warnings you describe but I have had problems where I placed the update in a separate directory which broke the pinned item in the task bar.

不确定您描述的警告但我遇到了问题,我将更新放在一个单独的目录中,该目录打破了任务栏中的固定项目。

One approach is to have thin loader which is installed once and then loads the updated program into its own memory space. That way it will be identified as the same program if pinned in the task bar.

一种方法是使用一次安装的瘦加载器,然后将更新的程序加载到它自己的存储空间中。这样,如果固定在任务栏中,它将被识别为相同的程序。

I'm only familiar with using .NET AppDomain but I assume most other runtimes can do it as well.

我只熟悉使用.NET AppDomain,但我认为大多数其他运行时也可以这样做。

#1


0  

Hmm ClickOnce w/ .NET works great for this... Don't know what you mean by windows 7 complaining about the exe however.

嗯ClickOnce w / .NET非常适合这个...不知道你的意思是Windows 7抱怨exe。

#2


0  

Not sure about the warnings you describe but I have had problems where I placed the update in a separate directory which broke the pinned item in the task bar.

不确定您描述的警告但我遇到了问题,我将更新放在一个单独的目录中,该目录打破了任务栏中的固定项目。

One approach is to have thin loader which is installed once and then loads the updated program into its own memory space. That way it will be identified as the same program if pinned in the task bar.

一种方法是使用一次安装的瘦加载器,然后将更新的程序加载到它自己的存储空间中。这样,如果固定在任务栏中,它将被识别为相同的程序。

I'm only familiar with using .NET AppDomain but I assume most other runtimes can do it as well.

我只熟悉使用.NET AppDomain,但我认为大多数其他运行时也可以这样做。