首页 > 代码库 > win7加入域的脚本

win7加入域的脚本

这个先用txt编辑,保存后将“.txt”更改成“.vbs”的后缀。

 

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 = "域名(例如baidu.com)"
 strPassword = "域管理员密码"
 strUser = "administrator(域管理员)"
 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

本文出自 “11636656” 博客,请务必保留此出处http://11646656.blog.51cto.com/11636656/1877714

win7加入域的脚本