內容如下:
個人整理的,平時也有在用,切實可行,按照你的需要修改吧,把下列代碼拷貝到寫字板中,另存為:**.vbs,要用時雙擊就好了,是IT的都看懂:
可以實現:
- 自定議電腦名稱
- 自動加入網域
- 自動添加 域賬號 到 客戶機 POWER USER權限
- 刪除 本機 ADMINISTRATORS中除 ADMINISTRATOR 及 DOMAIN ADMIN以外的帳號
- 修改本機 ADMINISTRATOR密碼為 自己想要的密碼
'********************** '定義數據 '********************** Dim reval Dim computer_name1 Dim computer_name2 Dim computer_name3 Dim computer_name4 Dim computer_name5 '********************** '電腦名稱命名規則 '********************** MsgBox "行政公關:0210-英文名;財務會計:0220-英文名;" _ & "機構工程:0710-英文名;電子測試:0730-英文名;" _ & "新產品:0800-英文名",vbokcancel+vbexclamation, _ "電腦名稱命名規則!" '********************** '用戶自定義電腦名稱 '********************** Set objnet = CreateObject ("WScript.Network") Set R = CreateObject("WScript.Shell") reval = InputBox ("你當前的電腦名稱是:" _ & objnet.ComputerName,"請輸入新的電腦稱:") '********************** '存儲變量 '********************** computer_name1 = reval computer_name2 = reval computer_name3 = reval computer_name4 = reval computer_name5 = reval '********************** '修改電腦名稱 '********************** On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set colComputers = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For Each objComputer in colComputers errReturn = ObjComputer.Rename (computer_name1) ' If reval <> "" Then ' return=MsgBox ("請按確定重新啟動電腦", vbokcancel+vbexclamation, "注意!") ' If return=vbok Then ' R.run("Shutdown.exe -r -t 0") ' End if ' End If Next '********************** '加入XXXXX-CHINA域 '********************** '* http://support.microsoft.com/kb/222525 '* MAIL: tjq_wzy@hotmail.com '********************** 'strDomain需更改成自己域名 'strPassword及strUser具有權限加域的密碼及用戶 '********************** 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 = "xxxxx-china.cn" strPassword = "xxxxx-china" strUser = "admin" '有domain admins權限的用戶及密碼 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) wscript.echo "已成功加入xxxxx-CHINA.CN域!" ' wscript.echo "Pls. Reset Your Computer!" '******************************* '添加用戶到POWER USERS群組 '以下第二句WinNT://後為自己的域名 '******************************* dim myname myname = InputBox ("請輸入你申請賬號時的英文名稱,輸入錯誤將不能登錄:","自定義開機用戶名!") Set objGroup = GetObject("WinNT://" & computer_name2 & "/Power Users") Set objUser = GetObject("WinNT://xxxxx-china/" & myname) objGroup.Add(objUser.ADsPath) '*********************************** '刪除本地ADMINISTRATORS組中的其它成員 '除administrator 及 Domain Admins '*********************************** Set objGroup = GetObject("WinNT://" & computer_name3 & "/Administrators") For Each objUser In objGroup.Members If objUser.Name <> "Administrator" AND objUser.Name <> "Domain Admins" Then Wscript.Echo "刪除ADMIN群組賬號:" & objUser.Name objGroup.Remove(objUser.AdsPath) End If Next '*********************************** '修改本機管理員ADMINISTRATOR的密碼 '*********************************** '下面第三句引號部分為密碼字符 '*********************************** strComputer = "computer_name5" Set objUser = GetObject("WinNT://" & strComputer & "/Administrator, user") objUser.SetPassword "ks_its_" objUser.SetInfo '*********************************** '所有操作完成重新啟動電腦 '*********************************** 'wscript.echo "所有的操作完成,將重新啟動電腦!" 'Set objWMIService = GetObject("winmgmts:" _ ' & "{impersonationLevel=impersonate,(Shutdown)}!\\" _ ' & computer_name4 & "\root\cimv2") 'Set colOperatingSystems = objWMIService.ExecQuery _ ' ("Select * from Win32_OperatingSystem") 'For Each objOperatingSystem in colOperatingSystems ' ObjOperatingSystem.Reboot() 'Next return=MsgBox ("所有的操作完成,將重新啟動電腦!",vbokcancel+vbexclamation,"注意!") If return=vbok Then R.run("Shutdown.exe -r -t 0") End if '******************** 'end '********************
修改 Administrator 的密碼該程式段值得參考, 先收錄之.
沒有留言:
張貼留言