Click here to Skip to main content
15,881,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I am a bit confused trying to figure out why the registry value of type string does not change with the code that i am using

VB
Dim myReg As RegistryKey = Registry.LocalMachine
           Dim MyRegKey As RegistryKey
           Dim MyVal As String
           MyRegKey = myReg.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", True)
           MyVal = MyRegKey.GetValue("Shell")
               MyRegKey.SetValue("Shell", "%windir%\explorer.exe, explorer.exe", RegistryValueKind.String)



any help would be great thank you!!

This code throws no error and it requires admin privileges but the value will not seem to change in regedit?
Posted
Comments
TnTinMn 22-Nov-13 0:50am    
Is your application 32 bit running on a 64 bit OS?
If so, check: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon
for the changes.

Edit: If 64 bit OS and 32 bit application
For .Net 4.0 and above:
Dim myReg As RegistryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)

For .Net 3.5 and below, see: http://www.roelvanlisdonk.nl/?p=915

You have to run the program as an administrator to access registry.
 
Share this answer
 
Comments
Draco2013 21-Nov-13 23:20pm    
my question states that and i am aware of that but there is no change
This article describes how to elevate a process to run as admin. http://code.msdn.microsoft.com/windowsdesktop/CSUACSelfElevation-644673d3[^]

This article talk about impersonation before executing a code block that needs to be executed as admin.

http://stackoverflow.com/questions/1168571/run-code-as-a-different-user-c[^]
 
Share this answer
 
Comments
Draco2013 21-Nov-13 23:40pm    
Ok thank you for this but is there any problem with the code?
Draco2013 22-Nov-13 0:56am    
I like the elevated user link but have no idea why its important or useful to run the program as a different user?...

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