Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change registry key for all existing users

Status
Not open for further replies.

dohertys

Programmer
Jan 17, 2002
1
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top