"lolo1790" <> wrote in message
news:4086AD19-C251-44EE-945A-...
>i need vbs script to add computer in domain (OU ) with user and password.
> i need write each information in windows , is it possible, because i don't
> find this script.
>
> Thanks
I have used a script similar to below to join a computer to a domain. The
username and password are hardcoded, as are the domain and OU information:
============
' JoinDomain.vbs
' VBScript program to join a computer to a domain.
' The computer account is created in Active Directory.
' The computer must have XP or above.
' The AD must be W2k3 or above.
' See c:\Windows\debug\NetSetup.log for details.
Option Explicit
Dim strDomain, strUser, strPassword
Dim objNetwork, strComputer, objComputer, lngReturnValue
Dim strOU
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 = "MyDomain"
strPassword = "zXy321q$"
strUser = "administrator"
strOU = "ou=Computers,ou=West,dc=MyDomain,dc=com"
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:" _
& "{impersonationLevel=Impersonate,authenticationLev el=Pkt}!\\" & _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
strComputer & "'")
lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
strPassword, strDomain & "\" & strUser, strOU, _
JOIN_DOMAIN + ACCT_CREATE)
Wscript.Echo "ReturnValue = " & CStr(lngReturnValue)
--
Richard Mueller
MVP Directory Services
Hilltop Lab -
http://www.rlmueller.net
--