im trying to open a key so i can delete its subkeys
Code:Dim asu As New System.Security.Principal.NTAccount(username.Text) Dim si As System.Security.Principal.SecurityIdentifier = asu.Translate(GetType(System.Security.Principal.SecurityIdentifier)) Dim MyReg As Microsoft.Win32.RegistryKey MyReg = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, host.Text) _ .OpenSubKey("Software\Microsoft\Windows NT\currentVersion\ProfileList\" & si.ToString & "\") Dim myval As String myval = MyReg.GetValue("Guid") MsgBox(myval.ToString) ' retuns GUID no errors Dim guid As String guid = myval Dim MyReg2 As Microsoft.Win32.RegistryKey MyReg2 = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, host.Text) _ .OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileGuid\") MsgBox(MyReg2.ToString) 'myreg2.DeleteSubKey(guid)
now i have tesedt other keys on the same level
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileNotification
they all return values but trying to open ProfileGuid returns a Null reference - i have full access to the registry and have tested locally same results
i know the key exists is they any way i can delete it directly without opening subkeys? or can anyone help why it is returning null?




Reply With Quote
