推出C#的exe不会对Windows 7的UAC提示 [英] launch C# exe without prompting UAC on Windows 7

查看:280
本文介绍了推出C#的exe不会对Windows 7的UAC提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我想在Windows 7推出无DialogBox的要求运行作为管理员。所以在这里C#可执行文件是我的一个启动名为testApp.exe C#中的可执行程序代码内。

 过程testApp =新工艺(); 
testApp.StartInfo.FileName =C:\\Program Files\\Common Files\\testApp.exe
testApp.Start();



我也创建minfest两个程序。 app.manifest为testApp.exe和app.manifest为启动testApp.exe,然后我更改以下行两个舱单程序:



requestedExecutionLevel水平= requireAdministratoruiAccess =FALSE



当我双击了testApp.exe运行它,testApp.exe程序崩溃,但是当我运行它以管理员身份,它工作正常,没有崩溃。所以这behavoir也会发生同样的当我运行启动testApp.exe程序,testApp.exe崩溃。



我要在这里做了什么。我需要,因为我使用由Visual Studio 2010中生成的默认名称更改舱单的名称。



感谢。


< DIV CLASS =h2_lin>解决方案

其实你应该只使用




requestedExecutionLevel水平=requireAdministrator uiAccess =FALSE




只有当你想以管理员身份运行。



更改为:




requestedExecutionLevel水平=asInvokeruiAccess =FALSE




和你会好到哪里去。


I have C# executable that I want to launch on Windows 7 without the dialogbox asking for run-as-administrator.. So here is my code inside the program that launches the C# executable named testApp.exe.

Process testApp = new Process();
testApp.StartInfo.FileName = "C:\\Program Files\\Common Files\\testApp.exe";
testApp.Start();

I also create the minfest for both programs. app.manifest for testApp.exe and app.manifest for the program that launches testApp.exe, and then I change the following line in both manifest to:

requestedExecutionLevel level="requireAdministrator" uiAccess="false"

When I double click on the testApp.exe to run it, testApp.exe program crashes, but when I run it as administrator, it works fine, no crash. So this behavoir also happens the same when i run the program that launches the testApp.exe, testApp.exe crashes.

I must do something wrong here. Do I need to change the name of the manifest because I use the default names that are generated by visual studio 2010.

thanks.

解决方案

Actually you should only be using

requestedExecutionLevel level="requireAdministrator" uiAccess="false"

only when you want to run as administrator.

Change this to:

requestedExecutionLevel level="asInvoker" uiAccess="false"

And you'll be good to go.

这篇关于推出C#的exe不会对Windows 7的UAC提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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