Click here to Skip to main content
15,905,144 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Try
oReg = Registry.LocalMachine.OpenSubKey("Software", True)
oReg = oReg.CreateSubKey(RegSubKeyName)
oReg = Registry.LocalMachine.OpenSubKey("Software\\" & RegSubKeyName)
Catch ex As Exception
MsgBox(ex.Message)
'Application.Exit()
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?
Posted

How are you going to distribute the app. Can your setup create the registry key with valid permissions?
 
Share this answer
 
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?
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900