Hi All, Im developing a app that joins a computer to a domain, but having trouble implementing it using vb.net, any one assist or had the same issue. Much would be appericatied. Regards Dave Below is the code i have so far to join a computer to a domain :S
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
MsgBox(CStr(args(x)))
Next
retVal = comp.InvokeMethod("JoinDomainOrWorkgroup", args)
Next
Return retVal