.NET Answers

ASP.NET, HTML, CSS, Visual Studio, CSharp, VB.NET and other programming items of interest.
Subscribe

UnauthorizedAccessException writing to HKLM

April 08, 2008 By: Dave Category: none

Q. I’m trying to write to HKLM on a Vista computer using the following code:

Dim k As Microsoft.Win32.RegistryKey
k = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software", True)
k = k.CreateSubKey("subkey1\testprogram")
k.SetValue("foo", "bar")

But, when I get to the last line, the UnauthorizedAccessException is thrown.  How do I fix this?

(more…)

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!