John500
asked on
Cannot write to the registry key
I'm getting the following error when I try to write to the Vista registry:
System.UnauthorizedAccessE xception was unhandled
Message="Cannot write to the registry key."
Source="mscorlib"
StackTrace:
at Microsoft.Win32.RegistryKe y.EnsureWr iteable()
at Microsoft.Win32.RegistryKe y.SetValue (String name, Object value, RegistryValueKind valueKind)
at RegistryCheck.Program.Main (String[] args) in C:\RegistryCheck\Program.c s:line 75
at System.AppDomain._nExecute Assembly(A ssembly assembly, String[] args)
at Microsoft.VisualStudio.Hos tingProces s.HostProc .RunUsersA ssembly()
at System.Threading.Execution Context.Ru n(Executio nContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHel per.Thread Start()
I'm runing Visual Studio as Administrator but this doesn't make a difference. What am I missing - both for the sake of debug and as a final executable?
Thanks
System.UnauthorizedAccessE
Message="Cannot write to the registry key."
Source="mscorlib"
StackTrace:
at Microsoft.Win32.RegistryKe
at Microsoft.Win32.RegistryKe
at RegistryCheck.Program.Main
at System.AppDomain._nExecute
at Microsoft.VisualStudio.Hos
at System.Threading.Execution
at System.Threading.ThreadHel
I'm runing Visual Studio as Administrator but this doesn't make a difference. What am I missing - both for the sake of debug and as a final executable?
Thanks
ASKER
Thanks. The last post goes like this:
Sorry if I wasn't clear, but you have to enable "registry object access"
auditing, that is from regedit select the key you want to audit and add the
user or group you want to monitor. Then, using "Local Security Policy"
editor, you must turn-on; Local Policies - Audit Policy - Audit Object
Access for Failure. When done, each unsuccessful access will be logged in
security log and will contain the account used to modify a key or subkey.
Can you interpret this for me? How is this done? The writer states the requirement but doesn't demonstrate it.
Sorry if I wasn't clear, but you have to enable "registry object access"
auditing, that is from regedit select the key you want to audit and add the
user or group you want to monitor. Then, using "Local Security Policy"
editor, you must turn-on; Local Policies - Audit Policy - Audit Object
Access for Failure. When done, each unsuccessful access will be logged in
security log and will contain the account used to modify a key or subkey.
Can you interpret this for me? How is this done? The writer states the requirement but doesn't demonstrate it.
Try and disable the UAC first following these instructions:
http://www.mydigitallife.info/2006/12/19/turn-off-or-disable-user-account-control-uac-in-windows-vista/
This article also explains what vista changed regarding the administrator account...
http://www.mydigitallife.info/2006/12/19/turn-off-or-disable-user-account-control-uac-in-windows-vista/
This article also explains what vista changed regarding the administrator account...
ASKER
The UAC is turned off but this doesn't make a difference. As I said, I'm also running Visual Studio as administrator.
The article doesn't talk about C# code or .Net provisions for this problem......
The article doesn't talk about C# code or .Net provisions for this problem......
Please follow the instructions here:
http://kbase.gfi.com/showarticle.asp?id=KBID002902
http://kbase.gfi.com/showarticle.asp?id=KBID002902
ASKER
I don't get it - this article talks about enabling Auditing. If you want to log the changes that occur on a particular item then these steps would apply but not to C# code that needs access to the registry.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No, I didn't and that was the problem. Thanks!
How about taking a look at this question too please!
https://www.experts-exchange.com/questions/23872198/How-to-save-a-registry-key-value-to-string.html
How about taking a look at this question too please!
https://www.experts-exchange.com/questions/23872198/How-to-save-a-registry-key-value-to-string.html
http://bytes.com/forum/thread522485.html