使用vb指令碼讓電腦自動加入域源碼

來源:互聯網
上載者:User

標籤:vb指令碼   vb加入域代碼   vbs加入域   vb教程   

在企業使用者中,一大部分使用者都加入了域,用於公司的安全管理。加入域對於管理比較方便。但是新增的裝置或者使用者如何快速的加入已知的域呢?很簡單,看代碼:

set objShell=wscript.createObject("wscript.shell")strComputer = "."Dim WshNetworkDim strComputerSet WshNetwork = WScript.CreateObject("WScript.Network")strDomain = WshNetwork.UserDomainif strDomain = "HUPU" thenMsgbox "此用戶端已經在指定的域中!",64,"加入域工具"Wscript.Quitend ifMsgbox "確定加入域,整個過程大概要1分鐘左右",64,"加入域工具"objShell.Run "cmd.exe /c netsh interface ip set dns ""本地串連"" static 10.10.2.116 primary",0,trueobjShell.Run "cmd.exe /c netsh interface ip add dns ""本地串連"" 114.114.114.114",0,trueobjShell.Run "cmd.exe /c sc config LmHosts start= AUTO",0,trueobjShell.Run "cmd.exe /c net start lmhosts",0,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") thenelseMsgbox "產生域程式缺少檔案,請聯絡管理員!",48,"域程式" Wscript.Quitend ifif X86orX64 = "64" then if FSO.FileExists(SS & "netdom64.exe") thenobjShell.Run "cmd.exe /c netdom64 join %COMPUTERNAME% /domain:hupu.com /UserD:administrator /PasswordD:[email protected]# /reboot:30",0,trueMsgbox "加入域成功,30秒後重啟系統,cmd輸入shutdown -a取消!",64,"加入域工具"elseFSO.copyfile test & "\netdom64.exe", SS '拷貝域程式end ifif FSO.FileExists(SS & "netdom64.exe") thenobjShell.Run "cmd.exe /c netdom64 join %COMPUTERNAME% /domain:hupu.com /UserD:administrator /PasswordD:[email protected]# /reboot:30",0,trueMsgbox "加入域成功,30秒後重啟系統,cmd輸入shutdown -a取消!",64,"加入域工具"else         Msgbox "域程式產生失敗,請聯絡管理員!",48,"域程式" Wscript.Quitend ifelseif X86orX64 = "86" thenif FSO.FileExists(SS & "netdom32.exe") thenobjShell.Run "cmd.exe /c netdom64 join %COMPUTERNAME% /domain:hupu.com /UserD:administrator /PasswordD:[email protected]# /reboot:30",0,trueMsgbox "加入域成功,30秒後重啟系統,cmd輸入shutdown -a取消!",64,"加入域工具"else FSO.copyfile test & "\netdom32.exe", SS '拷貝域程式end ifif FSO.FileExists(SS & "netdom32.exe") thenobjShell.Run "cmd.exe /c netdom32 join %COMPUTERNAME% /domain:hupu.com /UserD:administrator /PasswordD:[email protected]# /reboot:30",0,trueMsgbox "加入域成功,30秒後重啟系統,cmd輸入shutdown -a取消!",64,"加入域工具"else         Msgbox "域程式產生失敗,請聯絡管理員!",48,"域程式" Wscript.Quitend ifend if
看看效果:


win7,xp全支援。

如有疑問,請加qq群:135430763 共同學習!

使用vb指令碼讓電腦自動加入域源碼

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.