Running only specific features as Administrator
-
Saturday, September 01, 2012 10:59 PM
Hi all,
Before you tell me about using the application manifests, please read my question carefully.
With a current project of mine, I am not wanting to run the application as Administrator. My clients need to be able to run the executable without Administrator privileges. However, for specific features in this application, Administrator privileges is required.
Now I ask, is it possible to open a "Require Administrator" dialogue in an event?
Friend WithEvents ButtonThatRequiresAdmin As New Button Private Sub ButtonThatRequiresAdmin_Click(sender As System.Object, e As System.EventArgs) Handles ButtonThatRequiresAdmin.Click ' If user is not already running as administrator Then ' Prompt for administrator access End Sub^ That's basically what I'm asking for help with.
EDIT: Like when they trigger an event that requires administrator access, how can I bring up the administrator dialogue?
Thanks,
- Jordan
Jordan St. Godard | Microsoft® Community Contributor 2011
double twoCents = .02; System.out.println("$" + twoCents);- Edited by Jordan St. Godard Saturday, September 01, 2012 11:01 PM Felt my question was unclear
All Replies
-
Sunday, September 02, 2012 12:46 AM
Have you thought about creating a separate executable for that piece that you want to launch requiring the admin rights? When that piece is launched it would require priveledge.There may be a way for partial admin within a call, but I am not aware of how to do it.
--
Mike- Marked As Answer by Jordan St. Godard Sunday, September 02, 2012 1:02 AM
-
Sunday, September 02, 2012 12:55 AM
Hi Mike,
Yes, I have considered using a separate executable for that part of the application but I would prefer using an admin call if it is indeed possible.
Thanks,
- Jordan
Jordan St. Godard | Microsoft® Community Contributor 2011
double twoCents = .02; System.out.println("$" + twoCents); -
Sunday, September 02, 2012 1:02 AM
Mike,
I just found that your answer is one of two ways possible. Unfortunately it seems I will have to create a second executable.
Source: http://stackoverflow.com/questions/17533/request-windows-vista-uac-elevation-if-path-is-protected/17544#17544 and http://stackoverflow.com/questions/1125020/elevation-without-restarting-an-applicationRequesting elevation mid-execution requires that you either:
Use a COM control that's elevated, which will put up a prompt
Start a second process that is elevated from the start.
In .NET, there is currently no way to elevate a running process; you have to do one of the hackery things above, but all that does is give the user the appearance that the current process is being elevated.
The only way I can think of to check if a path is UAC elevated is to try to do some trivial write to it while you're in an un-elevated state, catch the exception, elevate and try again.Jordan St. Godard | Microsoft® Community Contributor 2011
double twoCents = .02; System.out.println("$" + twoCents); -
Sunday, September 02, 2012 4:02 AM
What about Impersonation ? Something like this article
http://www.codeproject.com/Articles/14358/User-Impersonation-in-NET

