C# – launch C# exe without prompting UAC on Windows 7

cuacwindows 7

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.

Best Answer

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.