Link to home
Start Free TrialLog in
Avatar of ttobin333
ttobin333

asked on

VB6: How to temporarily elevate to administrator privileges

Dear Experts,

My VB6 program needs to access the internet to register its license when running in standard user mode. How can I get Windows Vista to ask for administrator approval with the standard dialog box for this operation and then return to standard user privileges right afterward?

Thanks!
Avatar of BrianGEFF719
BrianGEFF719
Flag of United States of America image

I believe that you have to take an action that requires administrator privileges and windows will issue the authentication request automatically.
Avatar of ttobin333
ttobin333

ASKER

Here's the problem: when the program tries to connect to the internet, Windows does not ask for admin approval, but the connection is blocked.  This is not a problem when logged in with admin privileges.  
Thanks egl1044!  I'm going to give it a try.
Uploaded the set of tools created to assist with elevations.
https://filedb.experts-exchange.com/incoming/ee-stuff/7778-vistauac.zip 
Thanks! Will test it out tonight!
Very sorry for delay--will complete testing within 1 day.
egl1044, this looks like exactly what I need, but I could use some guidance in putting it together.

Can I use any GUID value that the generator you supplied creates?

I have never used COM objects...can you provide some additional guidance for a beginner?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of nffvrxqgrcfqvvc
nffvrxqgrcfqvvc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks!
ttobin333.

I would like to update you with a VB.NET version if you ever decide to move to VB.NET or already have done so for some projects.
https://www.experts-exchange.com/articles/Programming/Languages/.NET/Visual_Basic.NET/VB-NET-Vista-COM-Elevation.html

-egl
HI egl1044

I need some help to implement this in Acc2007 on a Win7 box, can you assist? I can open another Q, I need step by step intrux on how to use your vistauac.zip for Acc2007.
The problem I am having is with CreateObject in Acc2007 VBA code:

Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Sheet")

I get the 'requested operation requires elevation' msg
Hi, LukeB
This won't work with what I think your trying to do.... It's for implementing COM elevation in your own COM/ActiveX dll's you compile. The reason it will fail is because there is strict requirments of registering the COM class for elevation something that you don't have control over with excel automation.
If you are using macros from within excel then I don't see a way around this unless you elevate the application itself using Run As Admin. However if you have access to VB6 where you can compile into an executable you "should" be able to elevate your process and use excel automation using early binding.
I recently removed all elevation articles for revision. I am in the process of re-working elevation into a toolkit for VB and .NET but there is no specific time frame when that will be finished.