Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Is it possible to elevate a program once it is already running in VB6?

Posted on 2007-11-15
5
640 Views
Last Modified: 2010-04-21
Because of a 3rd party software we incorporate we need to write the Registration Code to unlock it to the HKEY_LOCAL_MACHINE portion of the registry so it's available for all users.  And this needs to be done when the user is running after they purchase it as opposed to during installation.

Is there any way to elevate a program once it is running or to write to the HKEY_LOCAL_MACHINE in VB6 on Vista?  I don't care if the user gets the UAC prompt to allow it but I really don't want to have to have a completely separate registration program that runs in elevated mode to do it.  It's so much cleaner if it's kept inside of our main program.
0
Comment
Question by:rmcmanamy
  • 3
  • 2
5 Comments
 
LVL 34

Expert Comment

by:sramesh2k
ID: 20306957
Calling the ShellExecute function passing "runas" (instead of "open") will do the trick. Also, to add a "shield" icon to the command button, see this post:

http://groups.google.com/group/microsoft.public.de.vb/msg/1fc55a994d516405
0
 

Author Comment

by:rmcmanamy
ID: 20307502
Thanks but I was hoping there was some way to elevate it nce it was running already.  Basially we ae trying to store our registration information and I didn't want to have to shell out to another program to do it.  I would have thought Microsoft wouldhave been smart enough to think of this situation and give a way to ask for the securiy credintials or something when you are trying to write to the HKEY_LOCAL_Machine and have it prompt the user.
0
 
LVL 34

Expert Comment

by:sramesh2k
ID: 20308072
Here is a sample written for VB.NET but it should give you an idea on how to accomplish this. When the application first starts, let it check the registry to know if there is a registration code already present. If it's missing (probably a first run of the app), then restart the app elevated, using Shellexecute.
0
 
LVL 34

Accepted Solution

by:
sramesh2k earned 500 total points
ID: 20308074
0
 

Author Closing Comment

by:rmcmanamy
ID: 31427351
Thanks that should work I guess.  It still seams strange that Microsoft didn't think far enough ahead to let one just elevate the RegOpenKeyEx but I suppose there were security concerns with it.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question