简体   繁体   English

C#,UAC,安装程序,Windows 7

[英]C#, UAC, installer, Windows 7

I have a client-side app that downloads a Nullsoft installer from the server and runs the installer as an external process with verb set to "runas". 我有一个客户端应用程序,该应用程序从服务器下载Nullsoft安装程序,并将安装程序作为外部进程运行,并将动词设置为“ runas”。

Nullsoft installer also has a line in the script that requests elevated privileges. Nullsoft安装程序在脚本中也有一行请求提升特权。 On Windows 7, this works sometimes 在Windows 7上,有时可以使用

  • Windows displays the UAC dialog Windows显示UAC对话框
  • clicking OK allows the installer to run. 单击“ 确定”允许安装程序运行。

But other times, the UAC dialog never shows up, and as a result the installer never launches. 但是有时,UAC对话框永远不会显示,因此安装程序也不会启动。 If I manually double-click the same installer, it always works, ie the UAC dialog shows up, etc. 如果我手动双击相同的安装程序,它将始终有效,即显示UAC对话框等。

The most confusing part is this behavior being inconsistent, on the same machine with the exact same UAC settings this works sometimes and hangs the other times. 最令人困惑的部分是,这种行为是不一致的,在同一台计算机上具有完全相同的UAC设置,有时可以正常工作,而在其他时间挂起。 I have tried different UAC levels too, still it is hit-or-miss. 我也尝试过不同的UAC级别,但还是失败了。

Any ideas? 有任何想法吗?

What did you set RequestExecutionLevel to? 您将RequestExecutionLevel设置为什么? Just setting it to "RequestExecutionLevel admin" should be enough, no need to use the runas verb, just start the process with ShellExecute. 只需将其设置为“ RequestExecutionLevel admin”就足够了,无需使用runas动词,只需使用ShellExecute启动该过程即可。 (RequestExecutionLevel only deals with Vista and later when UAC is on, use the userinfo nsis plugin to cover those other cases) (RequestExecutionLevel仅适用于Vista,并且以后在启用UAC时,请使用userinfo nsis插件来解决其他情况)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM