自动加入域脚本

自动加入域的脚本最近公司在实施AD域方案,为减少工作量,研究了下自动加入域的脚本,还不错,基本上加入域的步骤都考虑进去去了,很方便.感谢小冯这段时间的帮助,使得我们能够共同提高.set objShel

自动加入域的脚本

最近公司在实施AD域方案,为减少工作量,研究了下自动加入域的脚本,还不错,基本上加入域的步骤都考虑进去去了,很方便.
感谢小冯这段时间的帮助,使得我们能够共同提高.

set objShell=wscript.createObject("wscript.shell")
wscript.echo "确定加入域,整个过程大概要1分钟左右。"

//连接到文件服务器上服务器,0表示CMD无前台黑窗提示,true表示只有前条正确执行后才执行下一条.
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服务状态为自动,并启动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服务实现加入域的功能
//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

标签: