注册表中的 RUNASADMIN 在 Windows 7 中似乎不起作用 [英] RUNASADMIN in Registry doesnt seem to work in Windows 7

查看:39
本文介绍了注册表中的 RUNASADMIN 在 Windows 7 中似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我的程序的安装程序使用以下代码使我的应用程序以管理员权限运行.但它在 Windows 7 下似乎没有效果.在 Vista 中它运行得很漂亮.如果我右键单击快捷方式并告诉它以管理员身份运行,程序将正常启动.但是通过使用下面的代码,应该使代码始终以这种方式运行程序.没有了.有谁知道Win 7是否仍然使用此密钥?顺便说一下,UAC 也在进行中.

For a while now the installer for my program has used the below code to make my app run with administer privileges. But it seems to have no effect under Windows 7. In Vista it worked beautifully. If I right click the shortcut and tell it to run as Administer, the program will start fine. But by using the below, code it should be made to run the program that way all the time. It doesn't anymore. Does anyone know if Win 7 still uses this key? UAC is also on by the way.

Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\
CurrentVersion\AppCompatFlags\Layers", "C:\App\app.exe", "RUNASADMIN");

谢谢.

推荐答案

我使用的是 Windows 7,我可以看到这样的键.但是,我认为这不是配置应用程序和安装程序的正确方法.

I am using Windows 7 and I can see such keys. However, I don't think that's a proper way to configure your application and installer.

我的建议是随应用程序 (app.exe) 分发清单文件.如果您使用的是 Visual Studio 2008,清单文件甚至可以轻松嵌入到可执行文件中.然后在清单文件中您可以要求管理员权限.

My recommendation is that you distribute a manifest file along with your application (app.exe). The manifest file can be even embedded in the executable easily if you are using Visual Studio 2008. Then in the manifest file you can require administrator rights.

http://msdn.microsoft.com/en-us/library/bb756929.aspx

http://blogs.msdn.com/shawnfa/存档/2006/04/06/568563.aspx

http://channel9.msdn.com/posts/jmazner/How-To-Tell-Vistas-UAC-What-Privelege-Level-Your-App-Requires/

这篇关于注册表中的 RUNASADMIN 在 Windows 7 中似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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