VBS脚本让客户机自动加入到域

'* Start Script
'***********************
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 = "sohu.com"
'domain需更改为自己域的名称               /*此行为描述所用*/
strPassword = "dir"
'有domain admins组权限的用户及密码       /*此行为描述所用*/
strUser = "zhang.san"                /*此行为描述所用*/
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 + ACCT_CREATE)
wscript.echo "命令己完成."
wscript.echo "请重启你的电脑!"
'*****************
'* End Script
'*****************

注:1、此文件中以后大家要改的地方就三个(1)sohu.com域名;(2)password密码;(3)username用户名;
   2、把此文件的内容复习保存为*.vbs就可以使用了。
    3、客户机的tcp/ip参数设置正确;
    己经在客户机上测试成功。请大家放心使用

你可能感兴趣的:(vbs)