Previously I had been using netdom.exe from the Server 2003 Support Tools to join computers to a domain automatically. However, using VBScript and WMI is slightly easier because it doesn't require any extra files.
The example below will create a new Computer object in the Active Directory OU that you specify. The following variables should be set according to your own environment:
strDomain - domain name
strUser - user id with rights to create a computer object
strPassword - the password for the user id specified in strUser
strOU - the Active Directory OU where the Computer object will be created, in FQDN format
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
strDomain = "DOMAIN_NAME"
strUser = "USER_NAME"
strPassword = "PASSWORD"
strOU = "ou=COMPUTERS,ou=TESTOU,dc=COMPANY,dc=COM"
Set objNetwork =...