如何为 Windows 安装程序创建清单?
我们的应用程序有一个安装程序,必须像许多其他安装程序一样以管理员权限下载和运行。但是,安装程序未命名为“setup.exe”,因此 Windows 不会自动检测到它需要提升才能运行。
坦率地说,更改安装程序名称以使事情正确提升听起来相当混乱。 这篇文章讨论了很多关于 UAC 和提升的内容,它说您可以使用清单来使某些内容需要授权。
因此,我们只想为我们的安装程序创建一个清单。但是,我们如何确保清单存在?如果用户只是下载 our_application_v13.exe,我们如何确保他们也获得清单? AFAIK 在这种情况下,清单必须是一个名为“our_application_v13.exe.manifest”的文件。
由于他们只是从我们的网站下载文件,我们如何确保他们也获得清单?我们可以以某种方式将其构建到可执行文件中,或者以其他方式将可执行文件标记为需要提升吗?我们使用的是数百年前的安装程序工具,我们无法更改,因此它没有任何与此相关的功能。
谢谢!
We have an installer for our application that must be downloaded and run with administrator privileges, like many other installers. However, the installer isn't named "setup.exe", so Windows doesn't automatically detect it as requiring elevation to run.
Changing the installer name to make things elevate properly sounds pretty messy, frankly. This article talks a lot about UAC and elevation, and it says that you can use a manifest to make something require authorization.
So, we'd just love to create a manifest for our installer. However, how do we ensure the manifest is present? If the user just downloads our_application_v13.exe, how do we ensure they get the manifest too? AFAIK the manifest would have to be a file named "our_application_v13.exe.manifest" in that case.
Since they're just downloading a file from our web site, how do we make sure they get the manifest too? Can we build it into the executable in some way, or otherwise flag the executable as requiring elevation? We are using an installer tool from hundreds of years ago that we can't change, so it doesn't have any capabilities relevant to this.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果安装程序工具允许您更改/附加/编辑生成的 EXE 文件的资源,则可以将清单文件添加为资源类型为 24(Windows 标头中的 RT_MANIFEST)且资源 ID 为 1 的资源。
如果安装程序工具没有插入资源的内置工具,那么您可能需要编写一个工具来对 install.exe 文件进行后处理以插入资源。查找 Windows API BeginUpdateResouce 和 EndUpdateResource。它们有一些限制 - 如果 EXE 根本不包含任何资源文件,它们往往无法工作,但大多数安装工具生成的 exe 文件至少包含版本信息资源。
此外,如果安装经过数字签名,则必须在插入清单资源后完成。
另外,mt.exe 包含在 Platform SDK 中,大多数版本的 Visual Studio 都具有嵌入、提取和合并清单资源的选项。
If the installer tool allows you to change/attach/edit the resources of the generated EXE file, you can add the manifest file as a resource with a resource type of 24 (RT_MANIFEST in the windows headers) and a resource id of 1.
If The installer tool does not have the built in facility to insert resources, then you might have to write a tool to post-process your install.exe file to insert the resource. Look up the Windows APIs BeginUpdateResouce and EndUpdateResource. They have some limitations - they tend not to work if the EXE doesn't already contain any resource files at all, but most install tool generated exe files contain at least a version info resource.
Also, if the install is digitally signed that will have to be done after insertion of the manifest resource.
Also, mt.exe included with the Platform SDK and most versions of visual studio has options to embed, extract and merge manifest resources.
清单也可以位于应用程序的本机资源部分(EXE 内部)。
The manifest can also be in the application's native resource section (inside the EXE).
Heaventools Software 提供资源调谐器控制台。
There is Resource Tuner Console from Heaventools Software.