Board logo

标题: [转贴] VBScript脚本添加到域 [打印本页]

作者: find    时间: 2012-3-4 19:27     标题: 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




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2