How can i start my application as "Run as Administrator" forcefully?
Asked Answered
R

1

6

In my application,I am writing some values in application settings file. As i am working with prism I have some module and one shell project. After installing setup

Case: 1

When i have not set compatibility mode as "Run as Administrator". Running application i am able write application settings for all modules but unable to write for main shell project.

Case: 2

When i have set compatibility mode as "Run as Administrator". Now i am able write settings for all.

Required Solution:

I want to set my application compatibility mode as administrator forcefully but don't know how to do it?

Reconstructionism answered 16/8, 2013 at 8:43 Comment(1)
"Required Solution" -> there's another, imo better, and that is to not write in the app settings file but in a user config file. Place it in ProgramData or so.Darondarooge
I
9

Add an app.manifest to your project. In there, under trustInfo --> security --> requestedPrivileges node, uncomment this line:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Then you're good to go.

Impasto answered 16/8, 2013 at 8:57 Comment(3)
when my application fetching some dll form Programfies/Company/My applicationat run time it gives me error as The Just-In-Time debugger was launched without necessary security permissionReconstructionism
it was my application dll problem not manifest problem.. and your suggestion works for me. Thanx...Reconstructionism
Correction, the manifest file should not be added to the solution, but to the project. (Right-click project in Solution Explorer and Add new item...)Khoury

© 2022 - 2024 — McMap. All rights reserved.