Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Windows 7上启动C#exe而不提示UAC_C#_Windows 7_Uac - Fatal编程技术网

在Windows 7上启动C#exe而不提示UAC

在Windows 7上启动C#exe而不提示UAC,c#,windows-7,uac,C#,Windows 7,Uac,我有一个C#可执行文件,我想在Windows 7上启动它,而不会出现要求以管理员身份运行的对话框。。下面是启动名为testApp.exe的C#可执行文件的程序中的代码 Process testApp = new Process(); testApp.StartInfo.FileName = "C:\\Program Files\\Common Files\\testApp.exe"; testApp.Start(); 我还为这两个程序创建了minfest。testApp.exe的app.man

我有一个C#可执行文件,我想在Windows 7上启动它,而不会出现要求以管理员身份运行的对话框。。下面是启动名为testApp.exe的C#可执行文件的程序中的代码

Process testApp = new Process();
testApp.StartInfo.FileName = "C:\\Program Files\\Common Files\\testApp.exe";
testApp.Start();
我还为这两个程序创建了minfest。testApp.exe的app.manifest和启动testApp.exe的程序的app.manifest,然后我将两个清单中的以下行更改为:

requestedExecutionLevel=“requireAdministrator”uiAccess=“false”

当我双击testApp.exe运行它时,testApp.exe程序崩溃,但当我以管理员身份运行它时,它工作正常,没有崩溃。因此,当我运行启动testApp.exe的程序时,这种行为也会发生,testApp.exe崩溃

我一定是做错了什么。我是否需要更改清单的名称,因为我使用的是visual studio 2010生成的默认名称


谢谢。

实际上,您应该只使用

requestedExecutionLevel=“requireAdministrator”uiAccess=“false”

仅当您希望以管理员身份运行时

将此更改为:

requestedExecutionLevel=“asInvoker”uiAccess=“false”

你就可以走了。

使用 info.Verb=“runas”//提供以管理员身份运行的50美分

而不是添加
requestedExecutionLevel=“asInvoker”uiAccess=“false”
在清单中,您可以使用任务计划程序在最高级别(管理员模式)下运行几乎所有内容

资料来源:


虽然上面的帖子谈到了远程运行,但您可以轻松地将其更改为本地运行。

请查看以下链接:感谢您的链接。帖子建议在清单中使用requireAdministrator,但我希望可执行文件在没有提示对话框的情况下运行administrator。感谢回复。我使用asInvoker,但它不能解决问题。当我拿出引用第三方DLL的代码时,它运行正常,但当我不注释掉时,它会崩溃。这意味着第三方DLL必须以提升模式运行,所以最好的选择是以管理员身份运行。绕过UAC提示符而不以管理员身份运行是一个漫长而复杂的过程。