?
Solved

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

Posted on 2007-11-15
5
Medium Priority
?
647 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
[X]
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
  • 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 1500 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

650 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