Writing  to registry in vb.net   2013

tompowers2474
tompowers2474 used Ask the Experts™
on
Hey Guys

I am clueless yes  I write in VB .NET CAUSE I'M NOT THAT GOOD AT  PROGRAMMING ANYWAY ALL I WANT  TO DO IS JUST  WRITE  A FEW VALUES FOR A AUTOLOGON USING VB.NET HOW WRONG  AM I

Imports Microsoft.Win32

Public Class Form1
    Dim regKey As RegistryKey
    Dim regKey1 As RegistryKey

    Dim regKey2 As RegistryKey
    Dim regKey3 As RegistryKey
    ' Public Function  
    Public Function CreateSubKey(subkey As String, permissionCheck As Microsoft.Win32.RegistryKeyPermissionCheck) As Microsoft.Win32.RegistryKey
    End Function
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        txtTimeandDATE.Text = Date.Now
    End Sub
    Public Sub Labs()
        txtPass.Text = "Nazareth1"
        regKey = Registry.LocalMachine.CreateSubKey("\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", True)
        regKey.SetValue("AutoAdminLogon", "1")
        regKey1 = Registry.LocalMachine.CreateSubKey("\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", True)
        regKey1.SetValue("DefaultDomainName", "ONE")
        regKey2 = Registry.LocalMachine.CreateSubKey("\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", True)
        regKey2.SetValue("DefaultUserName", cmbUser.SelectedValue)
        regKey3 = Registry.LocalMachine.CreateSubKey("\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", True)
        regKey3.SetValue("DefaultPassword", txtPass.Text)
    End Sub

Open in new window

please help thanks guys
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior .Net Consultant
Top Expert 2016
Commented:
What is the issue that you have? I see that you are trying to write to HKLM. You should write to HKCU (current user). HKLM requires privileges.

Also have a look at http://emoreau.com/Entries/Articles/2003/10/Using-the-registry-from-a-VBNet-application.aspx

Author

Commented:
Thank You

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial