Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Writing to the HKEY_LOCAL_MACHINE in the registry with UAC turned on

Posted on 2011-03-10
8
Medium Priority
?
226 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 43

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 43

Accepted Solution

by:
pcelba earned 500 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 30

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 500 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 43

Expert Comment

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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

916 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