电脑批量加入域控制器脚本

$strpasswd=" 能加域账号的密码密码"
$struser="能加域的账号"
$strdomain="域名"

$name=InputBox("装机一键设置V2.3","请输入计算机名称","C")
If @error>0 Then Exit
$fso =ObjCreate("Scripting.Filesystemobject")
For  $dr In $fso.Drives
        If $dr.DriveType = 2 And $dr.DriveLetter <> "C" Then
        RunWait("cacls.exe " & $dr.DriveLetter & ":\  /E /C /G everyone:F")
                Sleep(1000)
        EndIf
    Next
;FileInstall("D:\jd.vbs",@StartupDir & "\jd.vbs")
FileInstall("D:\jd.vbs","C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\jd.vbs")
$strComputer = "." 
$objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
$colcomputers= $objWMIService.ExecQuery("Select * from Win32_ComputerSystem", "WQL", 0x30)
For  $colcomputer in $colcomputers
   $colcomputer.UnjoinDomainOrWorkgroup($strpasswd, $strdomain & "\" & $struser, 2)
   $colcomputer.rename($name)
Next
Sleep(5000)

Shutdown(2)


加域 改计算机名 给其他盘符 everyone权限 设置管理员密码 的脚本


====================================================================================================


On Error Resume Next
set WshShell = CreateObject("wscript.Shell")
wshshell.Run "net user administrator ****"
wshshell.Popup "正在加域,请稍后!", 1
Const struser="****"
Const strpasswd="*****"
a=0
While a=0
strComputer = "."
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address ='klsz.com'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
wshshell.Popup "连不上klsz.com!3秒后重试", 1
wscript.sleep 3000
else
a=1
end if
next
wend
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colcomputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each colcomputer In colcomputers
strdomain=colcomputer.domain
colcomputer.joinDomainOrWorkgroup "KLSZ.COM",strpasswd,strdomain & "\" & struser,Null,2+1
next
wscript.sleep 1000
Set fso = CreateObject("scripting.filesystemobject")
fso.DeleteFile"C:\Documents and Settings\Administrator\「开始」菜单\程序\启动\jd.vbs"

wshshell.Popup "加域成功,系统即将重启!", 1
wshshell.Run "shutdown.exe -r -t 0"


--------


这是JD.vbs 部分

你可能感兴趣的:(windows,Microsoft,计算机,控制器,Everyone)