我需要做什么才能确保我的应用程序以管理员身份启动?
我正在编写一个应用程序,允许您将 Wiimote 上的按钮编写为 PC 上的操作的脚本。目前它支持主遥控器的所有功能(扬声器除外)。
现在,当我在打开 UAC 的 Vista 上运行它时,我遇到了麻烦。
每当 UAC 窗口获得焦点时,我的应用程序都无法成功移动鼠标。例如,当安装程序运行时,我必须使用键盘进行导航。
以管理员身份运行应用程序可以解决我的问题吗?(在某个时间点,我能够成功地将鼠标移到 UAC 密码输入框上)如何构建一个将告诉 Windows“以管理员身份运行”的清单?如果我对程序集进行强命名,如何将此清单嵌入到我的应用程序中?
如何使用 Authenticode 证书签署我的应用程序?
编辑:
好的,因此,经过一些更广泛的研究,我发现:
http://msdn.microsoft .com/en-us/library/bb756929.aspx
<requestedExecutionLevel
level="asInvoker|highestAvailable|requireAdministrator"
uiAccess="true|false"/>
然而,文章说:
带有 uiAccess 标志的应用程序 设置为 true 必须是 Authenticode 签名即可正常启动。此外, 该应用程序必须驻留在 文件系统中受保护的位置。 \Program Files\ 和 \windows\system32\ 目前这两个是允许的 受保护的位置。
我编辑了这个问题以反映新的进展。
I'm writing an app that allows you to script the buttons from a wiimote into actions on your PC. It currently supports all of the features of the main remote control, except for the speaker.
Now, I'm running in to trouble when I run it on Vista with UAC turned on.
Any time a UAC'd window has focus, my app fails to move the mouse successfully. For instance, when an installer is run, I have to navigate it with the keyboard.
Will running the app as administrator solve my problem?(At one point in time, I was able to successfully move the mouse over a UAC-password-entry box)How do I build a manifest that will tell windows to "run as administrator"?How do I embed this manifest into my app, if I'm strongly naming my assembly?
How do I sign my application with an Authenticode cert?
EDIT:
Ok, so after some more extensive research, I have found:
http://msdn.microsoft.com/en-us/library/bb756929.aspx
<requestedExecutionLevel
level="asInvoker|highestAvailable|requireAdministrator"
uiAccess="true|false"/>
However, the article says:
Applications with the uiAccess flag
set to true must be Authenticode
signed to start properly. In addition,
the application must reside in a
protected location in the file system.
\Program Files\ and \windows\system32\
are currently the two allowable
protected locations.
I have edited the question to reflect the new developments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
3:这取决于你的开发环境。如果您找不到嵌入清单的选项,则可以将其部署为外部清单文件与 .exe 一起部署。例如,如果您的 .exe 名为 MyProg.exe,请将清单放置在名为 MyProg.exe.manifest 的文件中。
请注意,自 Windows Server 2003 及更高版本起,任何内部清单都优先于外部清单。
还有 MT.exe 工具。
4:参见示例 http://www.tech-pro.net /code-signing-for-developers.html
3: This depends on your development environment. If you cant find an option to embed a manifest, you can instead deploy it as an external manifest file alongside your .exe. For example, if your .exe is called MyProg.exe, place the manifest in a file called MyProg.exe.manifest
Notice that since Windows Server 2003 and later, any internal manifest is preferred over an external manifest.
There's also the MT.exe tool.
4: See for example http://www.tech-pro.net/code-signing-for-developers.html