How does a program ask for administrator privileges?

心不动则不痛 提交于 2019-11-29 10:39:50

You can edit the UAC Settings (in VB 2008) which is located in the Project Settings. Look for the line that says

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

Change level="asInvoker" to

  1. level="asInvoker" (same access token as the parent process)
  2. level="requireAdministrator (require full administrator)
  3. level="highestAvailable" (highest privileges available to the current user)

I have not done this yet but I believe you go to (in VS 2008) Project Settings -> Application Tab and click on the "View UAC Settings" button. This opens up your app.manifest file. In there is a tag which I think holds the options you're looking for. Mine has some options commented out which should get you started:

There are several articles on the Internet about developing elevated processes in Vista, but essentially elevation requests involve decorating .NET assemblies and WIN32 executables with elevation status in the application manifest file (may be embedded or side-by-side).

There is an excellent blog post about your question which provides the code you'll probably need:

.NET Wrapper for COM Elevation

Metexu

IN VS 2015: Go to: Project -> (name of project) Properties... -> Application -> View Windows Settings and find in app.manifest (line 19): And change asInvoker to:

  1. "asInvoker" (same access token as the parent process)
  2. "requireAdministrator (require full administrator)
  3. "highestAvailable" (highest privileges available to the current user)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!