自動加入域腳本
自動加入域的腳本最近公司在實施AD域方案,為減少工作量,研究了下自動加入域的腳本,還不錯,基本上加入域的步驟都考慮進去去了,很方便.感謝小馮這段時間的幫助,使得我們能夠共同提高.set objShel
自動加入域的腳本
最近公司在實施AD域方案,為減少工作量,研究了下自動加入域的腳本,還不錯,基本上加入域的步驟都考慮進去去了,很方便.
感謝小馮這段時間的幫助,使得我們能夠共同提高.
set objShell=wscript.createObject("wscript.shell")
wscript.echo "確定加入域,整個過程大概要1分鐘左右。"
//連接到文件服務器上服務器,0表示CMD無前臺黑窗提示,true表示只有前條正確執(zhí)行后才執(zhí)行下一條.
objShell.Run "cmd.exe /c net user username password",0,true
objShell.Run "cmd.exe /c label d: d",0,true
objShell.Run "cmd.exe /c echo d|convert d: /fs:ntfs /x",0,true
objShell.Run "cmd.exe /c reg add ""HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorer
AdvancedFolderSimpleSharing"" /v ""DefaultValue"" /t reg_dword /d ""00000000"" /f>nul",0,true
objShell.Run "cmd.exe /c reg add ""HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorer
AdvancedFolderSimpleSharing"" /v ""CheckedValue"" /t reg_dword /d ""00000000"" /f>nul",0,true
objShell.Run "cmd.exe /c reg add ""HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorer
AdvancedFolderSimpleSharing"" /v ""UncheckedValue"" /t reg_dword /d ""00000000"" /f>nul",0,true
//修改本地連接主DNS為PDC服務器地址,如果PDNS和PDC做在同一服務器上的話.修改輔助DNS為10.10.10.11,
objShell.Run "cmd.exe /c netsh interface ip set dns ""本地連接"" static 10.10.10.10 primary",0,true
objShell.Run "cmd.exe /c netsh interface ip add dns ""本地連接"" 10.10.10.11",0,true
//修改TCP NETBIOS服務狀態(tài)為自動,并啟動netbios服務,不然會提示加入域失敗.
objShell.Run "cmd.exe /c sc config LmHosts start= AUTO",0,true
objShell.Run "cmd.exe /c net start lmhosts",0,true
//連接文件服務器,拷貝一個設置好的用戶配置文件模板作為新建用戶的配置. 新建D:?ckup 目錄 并修改注冊表默認新建帳號的配置文件目錄為D:?ckup
objShell.Run "cmd.exe /c net use .10.10.100 password /user:netsun",0,true
objShell.Run "cmd.exe /c md d:?ckup",0,true
objShell.Run "cmd.exe /c xcopy "".103.33.7軟件?fault User"" ""d:?ckup?fault User"" /E /H /k",0,true
objShell.Run "cmd.exe /c reg add ""HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionProfileList"" /v ""ProfilesDirectory"" /t reg_expand_sz /d ""d:?ckup"" /f>nul",0,true
//使用winmgmts服務實現(xiàn)加入域的功能
//strDomain = "domain.local" 域名
//strPassword = "user"
//strUser = "password"
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 = "domain.local"
strPassword = "user"
strUser = "password"
Set objNetw