为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

自动加域脚本 改计算机名加域加用户到本地管理员组

2019-08-20 11页 doc 31KB 132阅读

用户头像

is_337177

暂无简介

举报
自动加域脚本 改计算机名加域加用户到本地管理员组一共有三个脚本。第一个是改计算机名然后重启。第二个是加域和加用户账号到本地管理员组。第三个是删除痕迹和重启 这里计算机名的命名方法是:cis+ domainaccount+00 (site 简写+用户账号+用户第几台计算机,可以根据需要调整计算机名 你只需要运行第一个脚本changename.vbs 然后会弹出一个窗口叫你输入计算机名。余下的就有脚本帮你完成了。 changename.vbs '**************************************************************...
自动加域脚本 改计算机名加域加用户到本地管理员组
一共有三个脚本。第一个是改计算机名然后重启。第二个是加域和加用户账号到本地管理员组。第三个是删除痕迹和重启 这里计算机名的命名方法是:cis+ domainaccount+00 (site 简写+用户账号+用户第几台计算机,可以根据需要调整计算机名 你只需要运行第一个脚本changename.vbs 然后会弹出一个窗口叫你输入计算机名。余下的就有脚本帮你完成了。 changename.vbs '****************************************************************************** ******************************** 'Description: Change computer name reboot the system and auto login system with administrator ' 'author: Bo.zhang@lsi.com 'time : 08/30/2010 ' '****************************************************************************** ******************************** 'Option Explicit 'On Error Resume Next Const HKey_LOCAL_MACHINE = &H80000002 Dim strComputer Dim newComputerName Dim strKeyPath Dim strKeyPathTCPIP Dim objReg Dim objSysInfo 'Dim computerPath 'Dim arrDirectoryLocation() 'Dim i 'Dim strLocation 'Dim ouPath strComputer = "." strKeyPath = "SYSTEM\CurrentControlSet\Control\ComputerName\" strKeyPathTCPIP = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" Set objReg = GetObject("WinMgmts:{impersonationLevel=Impersonate}!\\" & _ strComputer &"\root\default:StdRegProv") Set ShellObj = WScript.CreateObject("WScript.Shell") '*****************************************************make the script run one when system start ShellObj.RegWrite "HKey_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\addtod omain", "c:\windows\addtodomain.vbs" Set FSO = WScript.CreateObject("Scripting.FilesystemObject") '****************************** copy Files to local FSO.CopyFile "addtodomain.vbs", "c:\windows\addtodomain.vbs" Set NetObj = WScript.CreateObject("WScript.Network") WinDir = FSO.GetSpecialFolder(0) SysDir = FSO.GetSpecialFolder(1) On Error Resume Next WinPass="HKey_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\" 'Call changeRegInfo(newComputername) 'Call AutoLogon 'Call shutdown '**************************************FUNCTIONS***************************** ******************************************* 'Function changeRegInfo(newComputername) newComputerName = InputBox ("inpute your computer name") objReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPathTCP,"Hostname" objReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPathTCP,"NV Hostname" objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "ComputerName\",_ "ComputerName",UCase(newComputerName) objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "ActiveComputerName\",_ "ComputerName",UCase(newComputerName) objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPathTCPIP,"Hostname",LCase(newComputerName) objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPathTCPIP,"NV Hostname",LCase(newComputerName) 'End Function '****************************************************************************** ******************************************* Dim objFso Set objFso = WScript.CreateObject("Scripting.FileSystemObject") objFso.CopyFile "addtodomain.*", "c:\windows" ''****************************************************************************** ******************************************* 'Function AutoLogon Dim sUser, sPass ' sUser = InputBox("Enter Username to Autologin") ' sPass = InputBox("Enter Password") sUser = "administrator" sPass = "LSI1AdMiN" ShellObj.RegWrite WinPass & "AutoAdminLogon","1","REG_SZ" ShellObj.RegWrite WinPass & "DefaultPassword", sPass, "REG_SZ" ShellObj.RegWrite WinPass & "DefaultUsername", sUser,"REG_SZ" 'Set ShellObj = WScript.CreateObject("WScript.Shell") ' shellobj.Run "command.com /k"&"shutdown -r -t 0" ' WScript.QUIT "command.com /k"& 'End Function '****************************************************************************** ******************************************* Set ShellObj = WScript.CreateObject("WScript.Shell") shellobj.Run "shutdown -r -t 0" '****************************************************************************** ******************************************* 第二个脚本你需要在红色部分根据需要添加你公司的域和你的加入域时用的账号和密码 '****************************************************************************** ******************* 'Description: Join domian and add user account to local administrators group and reboot the system ' author:Bo.zhang@lsi.com ' Date:08/30/2010 '****************************************************************************** ******************** 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_INVOCA TION = 262144 strDomain = "yourdomain" strPassword = "********" strUser = "your account " Set objNetwork = CreateObject("WScript.Network") strComputer = objNetwork.Computername Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _ strComputer & "\root\cimv2:Win32_ComputerSystem.name='" & _ strComputer & "'") ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _ strPassword, _ strDomain & "\" & strUser, _ NULL, _ JOIN_DOMAIN + ACCT_CREATE) '****************************************************************************** **************** ' add useraccount to local admin group '****************************************************************************** ***************** Dim useraccount Set net = WScript.CreateObject("WScript.Network") local = net.ComputerName useraccount =Left(local,Len(local)-2) useraccount=Right(useraccount,Len(useraccount)-3) MsgBox useraccount DomainName = "lsi" set group = GetObject("WinNT://"& local &"/Administrators") on error resume next group.Add "WinNT://"& DomainName &"/"& UserAccount &"" CheckError sub CheckError if not err.number=0 then set ole = CreateObject("ole.err") MsgBox ole.oleError(err.Number), vbCritical err.clear else MsgBox "Done." end if end sub '****************************************************************************** **************** 'disable admin auto logon and reboot the system the system '****************************************************************************** **************** WinPass="HKey_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\" Set ShellObj = WScript.CreateObject("WScript.Shell") ShellObj.RegWrite WinPass & "AutoAdminLogon","0","REG_SZ" '****************************************************************************** **************** 'delete teh addtodomain in c:\windows '****************************************************************************** **************** ShellObj.Run ("""c:\windows\addtodomain.bat""") ', 0, True 'shellobj.Run "shutdown -r -t 0" 第三部分是重启删去在用户计算机里的脚本 '****************************************************************************** ******************************** addtodomain.bat (起这个名字跟第二个相同时应为我再用vbs copy 时我图省事,把addtodomain.* 都拷贝到本地。自然addtodomain.bat 也copy 过来的) (Dim objFso Set objFso = WScript.CreateObject("Scripting.FileSystemObject") objFso.CopyFile "addtodomain.*", "c:\windows" ) '****************************************************************************** ******************************** del /q c:\windows\addtodomain.vbs shutdown -r -t 0
/
本文档为【自动加域脚本 改计算机名加域加用户到本地管理员组】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索