使用vb脚本让电脑自动加入域源码

使用vb脚本让电脑自动加入域源码,第1张

概述在企业用户中,一大部分用户都加入了域,用于公司的安全管理。加入域对于管理比较方便。但是新增的设备或者用户如何快速的加入已知的域呢?很简单,看代码: set objShell=wscript.createObject("wscript.shell")strComputer = "."Dim WshNetworkDim strComputerSet WshNetwork = WScript.C

在企业用户中,一大部分用户都加入了域,用于公司的安全管理。加入域对于管理比较方便。但是新增的设备或者用户如何快速的加入已知的域呢?很简单,看代码:

set obJshell=wscript.createObject("wscript.shell")strComputer = "."Dim WshNetworkDim strComputerSet WshNetwork = WScript.CreateObject("WScript.Network")strDomain = WshNetwork.UserDomainif strDomain = "HUPU" then	MsgBox "此客户端已经在指定的域中!",64,"加入域工具"	Wscript.Quitend ifMsgBox "确定加入域,整个过程大概要1分钟左右","加入域工具"obJshell.Run "cmd.exe /c netsh interface ip set dns ""本地连接"" static 10.10.2.116 primary",trueobJshell.Run "cmd.exe /c netsh interface ip add dns ""本地连接"" 114.114.114.114",trueobJshell.Run "cmd.exe /c sc config LmHosts start= auto",trueobJshell.Run "cmd.exe /c net start lmhosts",trueFunction X86orX64()    On Error Resume Next    strComputer = "."    Set objWMIService = Getobject("winmgmts:\" & strComputer & "\root\cimv2")    Set colitems = objWMIService.Execquery("Select * from Win32_ComputerSystem",48)        For Each objItem in colitems        If InStr(objItem.SystemType,"86") <> 0 Then            X86orX64 = "86"        ElseIf InStr(objItem.SystemType,"64") <> 0 Then            X86orX64 = "64"        Else            X86orX64 = objItem.SystemType        End If    Next    End FunctionSet FSO = CreateObject("Scripting.fileSystemObject") WD = FSO.GetSpecialFolder(0)SS = FSO.GetParentFoldername(WD)SS = SS & "windows\system32\"test = createobject("Scripting.fileSystemObject").Getfile(Wscript.ScriptFullname).ParentFolder.Pathif FSO.fileExists(test & "\netdom64.exe") thenelseif FSO.fileExists(test & "\netdom32.exe") thenelse	MsgBox "生成域程序缺少文件,请联系管理员!",48,"域程序" 	Wscript.Quitend ifif X86orX64 = "64" then 	if FSO.fileExists(SS & "netdom64.exe") then		obJshell.Run "cmd.exe /c netdom64 join %COmpuTERname% /domain:hupu.com /UserD:administrator /PasswordD:hpQAZ!@# /reboot:30",true		MsgBox "加入域成功,30秒后重启系统,cmd输入shutdown -a取消!","加入域工具"	else		FSO.copyfile test & "\netdom64.exe",SS '拷贝域程序	end if		if FSO.fileExists(SS & "netdom64.exe") then		obJshell.Run "cmd.exe /c netdom64 join %COmpuTERname% /domain:hupu.com /UserD:administrator /PasswordD:hpQAZ!@# /reboot:30","加入域工具"	else         	MsgBox "域程序生成失败,请联系管理员!","域程序" 		Wscript.Quit	end ifelseif X86orX64 = "86" then	if FSO.fileExists(SS & "netdom32.exe") then		obJshell.Run "cmd.exe /c netdom64 join %COmpuTERname% /domain:hupu.com /UserD:administrator /PasswordD:hpQAZ!@# /reboot:30","加入域工具"	else 		FSO.copyfile test & "\netdom32.exe",SS '拷贝域程序	end if	if FSO.fileExists(SS & "netdom32.exe") then		obJshell.Run "cmd.exe /c netdom32 join %COmpuTERname% /domain:hupu.com /UserD:administrator /PasswordD:hpQAZ!@# /reboot:30","域程序" 		Wscript.Quit	end if	end if
看看效果:


win7,xp全支持。

如有疑问,请加qq群:135430763 共同学习!

总结

以上是内存溢出为你收集整理的使用vb脚本电脑自动加入域源码全部内容,希望文章能够帮你解决使用vb脚本让电脑自动加入域源码所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1271978.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存