none
在a 机器上查询b机器上的信息的时候,会提示SWbemLocator拒绝访问:使用的是winxp sp2 的机器,防火墙被完全关闭.郁闷中〉。。。。。。。。。。。。。。。。。。 RRS feed

  • 问题

  • strComputer = "be293d6d31"
    Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    Set objSWbemServices = objSWbemLocator.ConnectServer _
    (strComputer, "root\cimv2", "administrator", "test")
    Set colSWbemObjectSet = objSWbemServices.InstancesOf("Win32_Service")
    For Each objSWbemObject In colSWbemObjectSet
    Wscript.Echo "Name: " & objSWbemObject.Name
    Next

    在a 机器上查询b机器上的信息的时候,会提示SWbemLocator拒绝访问:使用的是winxp sp2 的机器,防火墙被完全关闭.郁闷中〉。。。。。。。。。。。。。。。。。。

     

    2007年8月2日 7:53

答案

  • 如果机器在Workgroup造成Access Denied的原因可能是ForceGuest issue,http://support.microsoft.com/default.aspx?scid=KB;EN-US;180548有详细介绍。
    您可以尝试将registry 设为0。

    以下代码可以远程将机器加入指定Domain:
    ' ------ SCRIPT CONFIGURATION ------
    strComputer = "<ComputerName>" ' e.g. joe-xp
    strDomain = "<DomainName>" ' e.g. rallencorp.com
    strDomainUser = "<DomainUserUPN>" ' e.g. administrator@rallencorp.com
    strDomainPasswd = "<DomainUserPasswd>"
    strLocalUser = "<ComputerAdminUser>" ' e.g. administrator
    strLocalPasswd = "<ComputerUserPasswd>"
    ' ------ END CONFIGURATION ---------

    '########################
    ' Constants
    '########################
    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

    '###########################
    ' Connect to Computer
    '###########################
    set objWMILocator = CreateObject("WbemScripting.SWbemLocator")
    objWMILocator.Security_.AuthenticationLevel = 6
    set objWMIComputer = objWMILocator.ConnectServer(strComputer, _
    "root\cimv2", _
    strLocalUser, _
    strLocalPasswd)
    set objWMIComputerSystem = objWMIComputer.Get( _
    "Win32_ComputerSystem.Name='" & _
    strComputer & "'")

    '###########################
    ' Join Computer
    '###########################
    rc = objWMIComputerSystem.JoinDomainOrWorkGroup(strDomain, _
    strDomainPasswd, _
    strDomainUser, _
    vbNullString, _
    JOIN_DOMAIN)
    if rc <> 0 then
    WScript.Echo "Join failed with error: " & rc
    else
    WScript.Echo "Successfully joined " & strComputer & " to " & strDomain
    end if 

     

    2007年8月2日 7:57