Running C # exe without UAC request on Windows 7

I have a C # executable that I want to run on Windows 7 without a dialog asking me to run as an administrator. So, here is my code inside the program that runs the C # executable called testApp.exe.

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

I also create 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 manifests:

requestExecutionLevel level = "requireAdministrator" uiAccess = "false"

When I double-click testApp.exe to run it, the testApp.exe program crashes, but when I run it as an administrator, it works fine, without crashing. Therefore, this behavior also occurs when you start the program that starts testApp.exe, and it fails when working with testApp.exe.

I have to do something wrong. I need to change the manifest name because I use the default names created by Visual Studio 2010.

thank.

+1
source share
3 answers

You should actually use

requestExecutionLevel level = "requireAdministrator" uiAccess = "false"

only if you want to run it as an administrator.

Change this to:

requestExecutionLevel level = "asInvoker" uiAccess = "false"

.

+2

info.Verb = "runas";//

0

50 ,

requestedExecutionLevel level="asInvoker" uiAccess="false" ( )

: http://www.liberalcode.com/2014/01/automating-run-as-administrator-from-c.html

, .

0

All Articles