I am trying to modify a registry keys to show hidden folders for all users who have existing profiles on a windows 7 PC using the following code:
Dim usrkey As RegistryKey = Registry.Users
Dim objkey As Object
Dim names As String() = usrkey.GetSubKeyNames()
Dim keyname As String
Dim regKey As RegistryKey
For i = 0 To UBound(names) - 1
keyname = names(i) & "\software\microsoft\windows\currentversion\explorer\advanced"
objkey = Registry.Users.OpenSubKey(keyname, True)
If Not objkey Is Nothing Then
Try
regKey = Registry.Users.OpenSubKey(keyname, True)
regKey.SetValue("Hidden", 1)
Catch
MsgBox("unable to set Hidden")
End Try
End If
Next
-----------------
After I run the program (using the "Run as administrator" option) and look at the registry key value for the users affected, the value is correct, but the change doesn't show up when I open an Explorer window. If I logout/login and check the registry value, it has gone back to its previous value(2).
Any ideas why this isn't working?
Thanks,
Stephanie
Dim usrkey As RegistryKey = Registry.Users
Dim objkey As Object
Dim names As String() = usrkey.GetSubKeyNames()
Dim keyname As String
Dim regKey As RegistryKey
For i = 0 To UBound(names) - 1
keyname = names(i) & "\software\microsoft\windows\currentversion\explorer\advanced"
objkey = Registry.Users.OpenSubKey(keyname, True)
If Not objkey Is Nothing Then
Try
regKey = Registry.Users.OpenSubKey(keyname, True)
regKey.SetValue("Hidden", 1)
Catch
MsgBox("unable to set Hidden")
End Try
End If
Next
-----------------
After I run the program (using the "Run as administrator" option) and look at the registry key value for the users affected, the value is correct, but the change doesn't show up when I open an Explorer window. If I logout/login and check the registry value, it has gone back to its previous value(2).
Any ideas why this isn't working?
Thanks,
Stephanie