Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a computer to a domain by way of a VBS script?

Status
Not open for further replies.

croag

MIS
Nov 8, 2001
49
0
0
US
Does anyone have a script that will add a computer to a 'ourdomain' ...and we can have our domain admin and pw in the VBS script (or any other script)? So..we can essentially just walk to the computer, click the file, and it adds the computer to the domain?


And restarts the computer if possible? Anyone heard of this?


This should work with windows 2000k and/or xp clients. (or 2 different scripts for each client os if possible)

Thanks,

croag
 
Here is the code for XP ...
============================================================
Wscript.sleep 50

Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144

strDomain = "cmg.convergys.com"
strPassword = "Unisys#3"
strUser = "alogin"

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

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
strComputer & "'")

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
strPassword, _
strDomain & "\" & strUser, _
NULL, _
JOIN_DOMAIN )
============================================================

For win2k u can use Netdom.exe.


HTH

Aslam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top