在Windows Vista上覆盖C:\ Program \ MyProg中的可执行文件 [英] Overwrite executable in C:\Program\MyProg on Windows Vista
问题描述
我希望我的程序进行自我更新(从ftp下载新的exe和/或其他文件),并且我在
I would like my program to update itself (downloading a new exe and/or some other files from ftp) and I used the recipe in the accepted answer to this question. Recap:
- 将运行程序重命名为old-mp.exe
- 直接以mp.exe下载更新
- 重新启动程序
这非常适合Windows XP.在Vista上存在问题,因为用户必须以管理员身份运行该程序才能正常工作.右键单击并选择以管理员身份运行"可能会困扰我的用户...有人知道解决此问题的方法吗?我非常喜欢简单的更新方法.
This works great for windows XP. On vista there is a problem, as the user must run the program as administrator for this to work. Rightclicking and selecting "Run as administrator" might be over my users heads... Does anyone know a way around this? I like the simple update method very much.
推荐答案
简单的选项是包括一个清单,该清单指定应用程序需要管理员权限.然后Vista将自动提示您进行权限提升.清单应该看起来像这样:
The simple option is to include a manifest that specifies that the application needs administrator rights. Then Vista will automatically prompt for the rights elevation. The manifest should look something like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="ApplicationName" type="win32"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
您可以使用mt.exe工具将其添加到现有应用程序中.
You can use the mt.exe tool to add it to an existing application.
或者,您可以在实际更新之前以管理权限重新启动程序.这样一来,用户就不必总是具有管理权限即可运行-只需在更新时即可.
Alternatively you can restart the program with administrative rights just before the actual update. That way the user won't need to run with administrative rights always - just when updating.
这篇关于在Windows Vista上覆盖C:\ Program \ MyProg中的可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!