找回密码
 加入
搜索
查看: 2549|回复: 6

AU3怎么操作才能让客户机自动加入域?

[复制链接]
发表于 2009-10-6 13:35:16 | 显示全部楼层 |阅读模式
求自动加入域代码?
 楼主| 发表于 2009-10-6 13:38:10 | 显示全部楼层
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

strdnsOne = InputBox("Please type your first DNS address","Input")
strdnsTwo = InputBox("Please type your second DNS address","Input")
strDomain = InputBox("Please type your domain name","Input")
strUser = InputBox("Please type your domain user name","Input")
strPassword = InputBox("Please type you domain user's password","Input")

strComputer = "."

Set objShell = CreateObject("Wscript.shell")

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrDNSServers = Array(strdnsone, strdnstwo)
    objNetCard.SetDNSServerSearchOrder(arrDNSServers)
Next

Set objNet = CreateObject("Wscript.network")
strComputerName = objnet.ComputerName

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

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

If returnvalue = 0 Then
        return =MsgBox("Now the script will reboot your computer.",vbOKOnly+vbInformation,"Information")
        If return = 1 Then objshell.Run("cmd /c shutdown.exe -r -t 0")
End if
发表于 2009-10-6 13:49:57 | 显示全部楼层
楼主仍旧不会使用搜索吗?
 楼主| 发表于 2009-10-6 15:35:17 | 显示全部楼层
楼主仍旧不会使用搜索吗?
pusofalse 发表于 2009-10-6 13:49

论坛上有吗?
 楼主| 发表于 2009-10-6 15:36:15 | 显示全部楼层
发表于 2009-10-6 16:00:59 | 显示全部楼层
我不知你是以什么为关键字搜索的,但论坛中有关“域”的帖子,我看到的就不下5个,其中也有解决的,就看你会否使用搜索了。
发表于 2009-10-6 17:14:10 | 显示全部楼层
用 NETDOM.exe
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-16 06:38 , Processed in 0.081550 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表