最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

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

来源:动视网 责编:小OO 时间:2025-09-24 20:50:36
文档

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

一共有三个脚本。第一个是改计算机名然后重启。第二个是加域和加用户账号到本地管理员组。第三个是删除痕迹和重启这里计算机名的命名方法是:cis+domainaccount+00(site简写+用户账号+用户第几台计算机,可以根据需要调整计算机名你只需要运行第一个脚本changename.vbs然后会弹出一个窗口叫你输入计算机名。余下的就有脚本帮你完成了。changename.vbs'**********************************************************
推荐度:
导读一共有三个脚本。第一个是改计算机名然后重启。第二个是加域和加用户账号到本地管理员组。第三个是删除痕迹和重启这里计算机名的命名方法是: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\\addtodomain", "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

   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           = 

Const MACHINE_PASSWORD_PASSED = 128

Const DEFERRED_SPN_SET        = 256

Const INSTALL_INVOCATION      = 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

'**********************************************************************************************

'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

文档

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

一共有三个脚本。第一个是改计算机名然后重启。第二个是加域和加用户账号到本地管理员组。第三个是删除痕迹和重启这里计算机名的命名方法是:cis+domainaccount+00(site简写+用户账号+用户第几台计算机,可以根据需要调整计算机名你只需要运行第一个脚本changename.vbs然后会弹出一个窗口叫你输入计算机名。余下的就有脚本帮你完成了。changename.vbs'**********************************************************
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top