[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[转贴] VBScript脚本添加到域

  1. Const JOIN_DOMAIN = 1
  2. Const ACCT_CREATE = 2
  3. Const ACCT_DELETE = 4
  4. Const WIN9X_UPGRADE = 16
  5. Const DOMAIN_JOIN_IF_JOINED = 32
  6. Const JOIN_UNSECURE = 64
  7. Const MACHINE_PASSWORD_PASSED = 128
  8. Const DEFERRED_SPN_SET = 256
  9. Const INSTALL_INVOCATION = 262144
  10. strDomain = "test"
  11. strPassword = "Password1"
  12. strUser = "administrator"
  13. Set objNetwork = CreateObject("WScript.Network")
  14. strComputer = objNetwork.ComputerName
  15. Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
  16.     strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
  17.         strComputer & "'")
  18. ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
  19.     strPassword, strDomain & "\" & strUser, NULL, _
  20.         JOIN_DOMAIN + ACCT_CREATE)
  21. ' wait
  22. WScript.Sleep(1000)
  23. ' restart
  24. Set objWMIService = GetObject("winmgmts:" _
  25.     & "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
  26.         strComputer & "\root\cimv2")
  27. Set colOperatingSystems = objWMIService.ExecQuery _
  28.     ("Select * from Win32_OperatingSystem")
  29. For Each objOperatingSystem in colOperatingSystems
  30.     objOperatingSystem.Reboot()
  31. Next
复制代码


http://bjyizhang.blog.51cto.com/113024/660608

返回列表