Click here to Skip to main content
14,603,917 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a program that creates a key in the registry to store infomration for the project. This program works on Windows XP but gives an error when executed on Windows 7. The error message is "Requested registry access is not allowed". Below is a copy of the code where the error occurs. The error is on the line:
oReg = Registry.LocalMachine.OpenSubKey("Software", True)

Dim oReg As RegistryKey
oReg = Registry.LocalMachine.OpenSubKey("Software", True)
oReg = oReg.CreateSubKey(RegSubKeyName)
oReg = Registry.LocalMachine.OpenSubKey("Software\\" & RegSubKeyName)
Catch ex As Exception
End Try

I have looked for an answer online and the only answer that I have come up with is that I have to manually set the permissions on the registry before executing this code. This is not an option for me. I will be distributing this app to other people and I do not want them to have to get into the reg editor and manually set permissions to make this work.
Is there anything I can do from code to make this work? Is there something that has to be done different for Windows 7?
Rate this:
Please Sign up or sign in to vote.

Solution 1

How are you going to distribute the app. Can your setup create the registry key with valid permissions?
Rate this:
Please Sign up or sign in to vote.

Solution 2

I have created a setup project to distribute the app. I have created a program for the install that checks if the DB already exists and if not copy a template DB to the correct location. I could also create the registry key in that code. Is there something I have to do to set the permissions on the key at the time is is generated?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100