首页 > 代码库 > 批量加入域
批量加入域
批量加入域
脚本在微软的网站脚本中心有的.
根据你的要求,可以先建立dhcp服务器,指定客户端dns到dc.然后可以将脚本共享让用户自己运行.脚本如下:
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 = "domain"
strPassword = "password"
strUser = "user"
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name=‘" & _
strComputer & "‘")
ReturnValue = http://www.mamicode.com/objComputer.JoinDomainOrWorkGroup(strDomain, _
strPassword, _
strDomain & "\" & strUser, _
NULL, _
JOIN_DOMAIN + ACCT_CREATE)
wscript.echo "计算机加入域完成!按确定后重新启动电脑!"
set ws=wscript.createobject("wscript.shell")
ws.run "shutdown -r -t 0",0
-----红色标记处为你实际域名,用户名和密码.(运行脚本前,请确保dns解析正常.
-----不建议用户自己运行.这个脚本实际上是省去了管理员的一些操作而已,脚本会泄露账号信息,用完可以将其禁用.
本文出自 “hongbifu” 博客,请务必保留此出处http://flambee.blog.51cto.com/112166/1572057
批量加入域