Hi
I think we can use the code as below to do the job.
The sample below will create a user account UserID and then add it into the
administators group in the computername
Module Module1
Sub Main()
'Create Account
On Error Resume Next
Dim strUser As String = "UserID"
Dim oDomain As Object = GetObject("WinNT://computername")
Dim oUser As Object = oDomain.Create("user", strUser)
If (Err.Number = 0) Then
oUser.SetInfo()
oUser.SetPassword("Password")
oUser.SetInfo()
End If
'Add to addministrators
strUser = "UserID"
Dim strGroup As String = "Administrators"
oDomain = GetObject("WinNT://computername")
Dim oGroup As Object = oDomain.GetObject("Group", strGroup)
oGroup.Add("WinNT://computername/" & strUser)
End Sub
End Module
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.