0

Is there an option in the application properties ? I cannot find anything that tells Visual Studio that my application will need to be run in an elevated state.

Bill Greer
  • 3,046
  • 9
  • 49
  • 80

1 Answers1

1

If you're just trying to do this on your development machine, you could:

Log in as the Administrator and run Visual Studio -OR- Right-click the Visual Studio shortcut and click "Run As" and supply the Administrator account credentials.

If this is for an application you are developing to live on a server where the server cannot be left logged in as an Administrator while your application runs, you should either:

  • Build in impersonation into the code of the application, so it will run as whatever account you want it to run under
  • Give that account Administrator privileges (if allowed) or choose an account that already has the desired privileges for the WindowsImpersonationContext.

Info on Impersonation:

Without information about your app, i.e. if it is a web app or standard exe or SharePoint web page, it's hard to give you more specific info. For .NET web apps, ensure you use Windows authentication and set your app pool to run under the account with Admin privileges. Note that you may still need to add the Impersonation code into your app where you need the higher privileges, even if it is running under that account.

For SP pages, you need SPSecurity.RunWithElevatedPrivileges(function(){ ... });

Community
  • 1
  • 1
vapcguy
  • 7,097
  • 1
  • 56
  • 52
  • It's an executable and I just want it to run "elevated". I don't know if that helps at all. I know I can right click the executable and set it to always run as administrator, I'm just not sure how to tell Visual Studio that is what I want, so when the user installs the app, it is marked with the run as administrator attribute. – Bill Greer Jun 26 '14 at 11:50
  • If it is a simple .exe and you don't want to do the impersonation code in the examples, an easy way is to set a scheduled task that runs with the account having the Administrator privileges. http://windows.microsoft.com/en-US/windows/schedule-task#1TC=windows-7 – vapcguy Jul 03 '14 at 00:27