Submitted By: Barry D

Adds domain users (including users from Windows NT 4.0 domains) to the local Administrators group.

Visual Basic
Edit|Remove
domain = InputBox("What is the Domain name?") 
myUser = InputBox _
    ("What NT LOGON NAME do you wish to add to the Local Administrator Group?")
myGroup = InputBox _
    ("What NT DOMAIN GROUP do you wish to add to the Local Administrator Group?")
 
strDomainGroup = "WinNT://" & domain & "/" & myGroup & ",group"

Set objDomainGroup = GetObject(strDomainGroup)

Set objNetwork = CreateObject("Wscript.Network")

strComputer = objNetwork.ComputerName

Set objLocalGroup = GetObject("WinNT://" & strComputer _
& "/Administrators,group")

If Not objLocalGroup.IsMember(objDomainGroup.AdsPath) Then
objLocalGroup.Add(objDomainGroup.AdsPath)
End If

strDomainUser = "WinNT://" & domain & "/" & MyUser & ",user"

Set objDomainUser = GetObject(strDomainUser)

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName

Set objLocalGroup = GetObject("WinNT://" & strComputer _
& "/Administrators,group")

If Not objLocalGroup.IsMember(objDomainUser.AdsPath) Then
objLocalGroup.Add(objDomainUser.AdsPath)

end IF