|
楼主 |
发表于 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 |
|