我已使用应用程序清单配置我的 .NET 应用程序来请求管理员权限。 我还使用signtool 对程序集进行了签名。 一切都运行良好 — 当您启动应用程序时,您会收到漂亮的 UAC 提示,其中包含应用程序的名称和签名证书的名称。
但是,当我从网络共享运行应用程序时,提升提示会显示通用可执行文件图标,而不是我的应用程序的图标。 如何让 UAC 提示显示我的应用程序图标?
I have configured my .NET application using an application manifest to request administrator privileges. I have also signed the assembly using signtool. Everything works great—when you start the application, you get the nice UAC prompt with the application's name and the name of the signing certificate.
However, when I run the application from a network share, the elevation prompt displays the generic executable icon, not my application's icon. How do I make the UAC prompt display my application's icon instead?
发布评论
评论(3)
我大概发现了。
UAC 运行在服务之上,我们看到的对话框位于桌面快照之上。 该服务只会显示对话框,就像在桌面上一样。
众所周知,服务在系统帐户(以及其他帐户)上运行。 这意味着它需要 SYSTEM 才能拥有我们正在启动的可执行文件的权限。 我仅将安全性分配给自己(除去系统)。
一旦我授予系统权限(仅限读取权限!),并启动该应用程序 - 它就会显示应用程序图标!
I probably found out.
UAC runs on top of a service, the dialog we see is on top of the desktop snapshot. The service would just display the dialog box as if it were on the desktop.
As we know services run on SYSTEM account (among few others). This means it needs SYSTEM to have rights on the executable we are launching. I assigned security to myself only exclusively (stripped out SYSTEM).
As soon as I gave rights to SYSTEM (read rights only!), and launched the application - it showed the application icon!
是否与以下问题有关: 为什么我的 .NET 应用程序在从网络驱动器运行时崩溃?
您的 .net 应用程序在网络共享上拥有除本地磁盘之外的其他权限。 更新到 3.5 SP1 通常可以解决此问题。 否则,请检查 .net 远程代码的策略。
您也可以尝试其他非 .net 应用程序(例如 procmon),该应用程序需要提升才能将其放在同一目录中,然后看看会发生什么。
Could it be related to the question: Why does my .NET application crash when run from a network drive?
That your .net application has other rights on the network share than on your local disk. Updating to 3.5 SP1 will normally remove this issue. Otherwise, check the policies for remote code for .net.
Also you could try an other non .net application (procmon for instance) which required elevation to put it in the same dir and see what happens.
显然这不是 .net 的问题,而是 UAC 的问题。
我通过将 systinternals 中的 procmon 放置在网络共享上来重现该行为,并看到了相同的差异。
当切换到提升的会话时,可能会使用另一个用户。 网络映射是在普通用户上完成的,因此在提升的会话中无法找到应用程序,因此无法显示图标?
您可以尝试执行以下操作以强制连接在提升的会话中有效:
\\your-network-location\share /user:;
\\your-network-location\share\procmon.exe
(为了安全起见,请避免使用映射驱动器)看看UAC提示是否改善?Apparently it's not something with .net, but with UAC.
I've reproduced the behavior by placing procmon from systinternals on a network share and saw the same difference.
Maybe it has something to do that when switching to an elevated session another user is used. The network mapping is done on the general user, so in the elevated session the application could not be found and therefor it's not possible to display the icon?
You could try to do the following to force the connection to be valid on in the elevated session:
\\your-network-location\share /user:<username> <password>
\\your-network-location\share\procmon.exe
(to be on the safe side avoid a mapped drive) and see if the UAC prompt improves?