Hey all i am trying to delete a key from the registery but i cant seem to get it correct.
My code looks like this:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim tmpKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
Dim foundKey As RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey(tmpKey, True)
If Not (foundKey Is Nothing) Then
foundKey.DeleteSubKey("Billy")
Else
MsgBox("not found")
End If
End Sub
The tree looks like this:
1
It keeps saying it can not find that key… Any help would be great.
David
I believe you are trying to delete a value(“Billy”) in the subkey(“Run”).
If so, you would need to use the DeleteValue() method instead of DeleteSubKey().