Hi Everyone,

How are we all? Im pretty new to vb.net but have worked with alot of vbs scripts. I have used vb scripts in past that prompts to change a computer name & joins it to a inputed domain name... i am currently working on little app in .net that changes a computer name then joins it to a domain. i have done abit of look around on MSDN (http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/67e679cd-e6ba-4a8a-b9c0-6c402af860d4) & other forums finding informtion on how to join a computer to the domain using the system.management.managementobjects....i have also looked in to call Windows Scripting Host (WSH) but can anyone point me in the right direction (Codewise) to achieve the following in an app:

  • Change Computer Name
  • Join to a desired domain
  • use AD Authentication

i am currently using the code to join computer to a Domain, Could u pleas

Dim args(4) As String 
        'Dim args2(2) As String 
        Dim retVal As Long 
        Dim comp As System.Management.ManagementObject 
        Dim comps As System.Management.ManagementObjectCollection 
        Dim clsComps As New System.Management.ManagementClass("Win32_ComputerSystem") 
        comps = clsComps.GetInstances() 
        For Each comp In comps 
            'This is used to unjoin the domain 
            ''args2(0) = "Password" 
            ''args2(1) = "User with privs" 
            ''args2(2) = "0" 
            ''comp.InvokeMethod("UnjoinDomainOrWorkgroup", args2) 
            'this is used to join the domain 
            args(0) = txtdomain.text 'Took out our FQDN for this posting
            args(1) = "txtpassword.text 'I took the password info out for this posting
            args(2) = txtadminaccount 'I changed the admin account info for this posting
            args(3) = "ou=Workstations" 
            args(4) = 1 
            For x = 0 To 4 
                'read back each value for debugging 
            retVal = comp.InvokeMethod("JoinDomainOrWorkgroup", args) 
        Return retVal

If you could assist much would be appreicated.


Edited by Sidiq: Spelling error in tittle...sorry

8 Years
Discussion Span
Last Post by Teme64
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.