autoit能否实现给机器加域
公司好多机器,能否用autoit来实现为公司的机器加域?一台台手工加太麻烦了,还要切换到超级用户权限在加域。如果可以的话,该如何做?我没有学过编程,这个autoit上手容易吗?
[ 本帖最后由 wenlata 于 2009-4-9 12:22 编辑 ] 怎么没人进来回复的啊?有高手进来看看嘛 帮你顶下 ,很快就有人来回答你le ! 透過WMI來變更Domain,不過沒接觸過Autoit的可能有困難
Func _RenameComputerName($cn)
Local $strComputer = "localhost"
Local $objWMIservice,$object,$colCN,$ComputerName,$Newname,$msgbox
Local $wbemFlagReturnImmediately = 0x10,$wbemFlagForwardOnly = 0x20
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colCN = $objWMIservice.ExecQuery("SELECT Name FROM Win32_ComputerSystem")
For $object In $colCN
$ComputerName = $object.ReName($cn)
Next
EndFunc
以上是變更電腦名稱的源碼,Join Domain的是JoinDomainOrWorkgroup
給你思路,其它的等高手出現啦!! 我是用netdom.exe这个程序配合au3脚本加域的,但是还得一台一台的运行。如果管理员账号统一的话可以把管理员帐号加到脚本里,但好像新的不支持那个命令了,是runas吧? 我觉得可以用autoit的按键功能,做个按键精灵类的加域
RunAs($sUserName, @ComputerName, $sPassword, 0, @COMSPEC & " /c rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,0")
WinWaitActive("系统属性")
Send("{right}")
Send("!c")
..... Func _NetJoinDomain($sDomain, $sServer = "", $sAccountOU = "", $sAccount = "", $sPswd = "")
Local $iResult
$iResult = DllCall("netapi32.dll", "int", "NetJoinDomain", _
"wstr", $sServer, _
"wstr", $sDomain, _
"wstr", $sAccountOU, _
"wstr", $sAccount, _
"wstr", $sPswd, _
"int", 1)
Return SetError($iResult, 0, $iResult = 0)
EndFunc ;==>_NetJoinDomain()
http://msdn.microsoft.com/en-us/library/aa370433(VS.85).aspx 微软有一个VBS的标准加域脚本,但我照着VBS脚本写出来的只能添加到工作组,无法加域,主要是joindomainorworkstation()这个函数不太明白,麻烦哪位写过的指导一下,谢谢! netdom 命令不是可以远程实现了吗?
直接在域控制器上运行以下命令就可以的啦,再用个批处理过一下,重启客户机就OK啦
NETDOM ADD 客户机名 /Domain:域名 /UserD:客户机管理员 /PasswordD:客管密码
附加选项:/server:要加到哪台域控制器 /OU:加到哪个OU组织下 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 = "FABRIKAM"
strPassword = "ls4k5ywA"
strUser = "shenalan"
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)
VBS脚本..
页:
[1]