如何为Windows安装程序创建清单? [英] How do I create a manifest for a windows installer?

查看:89
本文介绍了如何为Windows安装程序创建清单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个适用于我们应用程序的安装程序,与许多其他安装程序一样,该安装程序必须以管理员权限下载并运行.但是,该安装程序没有命名为"setup.exe",因此Windows不会自动将其检测为需要运行提升程序.

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.

坦率地说,更改安装程序名称以使一切正常升高听起来很混乱. 本文讨论了很多有关UAC和海拔的问题,并说您可以使用清单来使某些内容需要授权.

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.

因此,我们只想为我们的安装程序创建清单.但是,我们如何确保清单存在?如果用户只是下载our_application_v13.exe,我们如何确保他们也获得清单?在这种情况下,AFAIK清单必须是一个名为"our_application_v13.exe.manifest"的文件.

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.

谢谢!

推荐答案

如果安装程序工具允许您更改/附加/编辑生成的EXE文件的资源,则可以将清单文件添加为具有资源类型的资源24(在Windows标头中为RT_MANIFEST),资源ID为1.

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.

如果安装程序工具没有用于插入资源的内置工具,那么您可能必须编写一个工具来对install.exe文件进行后处理以插入资源.查找Windows API BeginUpdateResouce 和EndUpdateResource.它们有一些局限性-如果EXE根本不包含任何资源文件,则它们往往不起作用,但是大多数安装工具生成的exe文件至少包含版本信息资源.

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.

此外, mt.平台SDK附带的exe 和大多数Visual Studio版本都具有嵌入,提取和合并清单资源的选项.

Also, mt.exe included with the Platform SDK and most versions of visual studio has options to embed, extract and merge manifest resources.

这篇关于如何为Windows安装程序创建清单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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