Solved

Writing to the HKEY_LOCAL_MACHINE in the registry with UAC turned on

Posted on 2011-03-10
8
105 Views
Last Modified: 2016-05-30
In VB.Net, is there a way to write to HKEY_LOCAL_MACHINE with UAC turned on?   It works fine if UAC is off.

           
Dim regKey As Microsoft.Win32.RegistryKey
regKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(strKey)
regKey.SetValue(strValueName, strValue)
regKey.Close()

Open in new window

0
Comment
Question by:jdressing
8 Comments
 

Author Comment

by:jdressing
ID: 35094542
I accidentally included Foxpro Database Zone on this question and it won't let me remove the zone once it is added.  I wish Expert Exchange would not always default the zone to be the same as the last question. Sorry about that...
0
 
LVL 41

Expert Comment

by:pcelba
ID: 35096914
What is the reason of UAC switched on? To prevent unauthorised registry writes... and more, of course.

If you need to write into a common part of the registry then do it during installation process which also requires administrative rights and UAC messages confirmation. You should not write such contents during the application standard run.

All computers contain many additional places where you can store some user or application related info.
0
 

Author Comment

by:jdressing
ID: 35123114
Yes, UAC is supposed to block writing to the registry, but it is also supposed to prompt the user to allow it or deny it...  it is not prompting, it is just blocking.  
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 41

Accepted Solution

by:
pcelba earned 125 total points
ID: 35124464
This is OK. Application should know about Registry writting and if UAC is switched ON then application must elevate itself to adminstrator privilages.

If you would like to read more:
http://blogs.msdn.com/b/calvin_hsia/archive/2007/04/13/add-a-manifest-to-control-your-application-vista-uac-behavior.aspx
http://www.bigresource.com/VB-Run-an-exe-with-UAC-turned-on-Vista-Issue--XTrUmJZXta.html
0
 
LVL 29

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 125 total points
ID: 35127344
UAC does not automatically prompt for elevation. Pcelba links to a very VFP specific solution, but what's generally valid is that a manifest (embedded or not) will stat, if the whole application needs elevated priviliges or not.

Without such a demand for application elevation registry write to HKEY_LOCAL_MACHINE will not cause UAC to prompt for administrative priviliges but will be redirected to a virtualstore under HKEY_LOCAL_USER\<UserID>\Machine as stated here: http://msdn.microsoft.com/en-us/library/aa965884%28VS.85%29.aspx

This is the core of your problem and the way to prevent it is to embed a manifest into your exe requiring elevated privileges.

Heres a video showing what to do in your VB.net project to add the needed requiredExecutionLevel in the app.manifest http://www.youtube.com/watch?v=Z8JWbJzhFiY

Bye, Olaf.


0
 

Expert Comment

by:EE_AutoDeleter
ID: 41623841
I've requested that this question be deleted for the following reason:

                           
No comment has been added to this question in more than 21 days, so it is now classified as abandoned and is now flagged for deletion.


If there is a valid solution, please OBJECT and indicate the comments that are, or would otherwise lead to, a solution.


Use the specific format https:#axxxxxxxx for comment ID(s).


Also, please don't object simply because the author did not respond to your comment. While we understand this is frustrating, unfortunately we cannot force the author to return to the question. Unless you feel you have presented a valid, verifiable solution we'll simply delete the question.


Experts-Exchange Auto Deleter
0
 
LVL 41

Expert Comment

by:pcelba
ID: 41623842
Answers are relevant, split points between https:#a35124464  and  https:#a35127344 seems to be fair.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now