Reputation: 3416
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.
Upvotes: 1
Views: 11032
Reputation: 1
my 50 cents,
instead of adding
requestedExecutionLevel level="asInvoker" uiAccess="false"
in manifest you can use task scheduler to run almost anything in highest level (Administrator Mode)
source: http://www.liberalcode.com/2014/01/automating-run-as-administrator-from-c.html
although the above post talks about running it remotely, but you can easily change it to run locally.
Upvotes: 0
Reputation: 10054
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.
Upvotes: 2