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

Writing to the HKEY_LOCAL_MACHINE in the registry with UAC turned on

Posted on 2011-03-10
8
138 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 42

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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 42

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 42

Expert Comment

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

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.net Facial recognition software (time and attendance) 6 63
location of a form 2 25
FInd Image Control Gridview 3 21
VB.NET Textbox input validation 4 40
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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

861 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