WMI connect server error 'Access denied'

Discussion in 'Scripting' started by Ivan Abramov, Sep 29, 2009.

  1. Ivan Abramov

    Ivan Abramov Guest

    Hello.

    I have the VB6 code:

    Dim objSWbemLocator As Object, objSWbemServices As Object,
    colNetworkAdapters As Object
    Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    Set objWMIService = objSWbemLocator.ConnectServer(sComputer, , sUser,
    sPassword)

    While execution I get the 'Access denied' error in the last line.
    Everything is working well only in local computer.
    As soon as I try to connect to remote computer, the error appears.
    Computer name, user name and his password is correct.
    Computers are not in a domain but in LAN.
    What is incoorect?
    I need to read computers config info.

    Many thanks in advance.
     
    Ivan Abramov, Sep 29, 2009
    #1
    1. Advertisements

  2. The user name should be in the form <ComputerName>\<UserName>, where
    <ComputerName> is the NetBIOS name of the computer and <UserName> is the
    name of the local user. The user should be a member of the local
    Administrators group (on the target computer).

    Also, shouldn't you specify the namespace, such as:

    Set objWMIService = objSWbemLocator.ConnectServer(sComputer, "root\cimv2" ,
    sUser, sPassword)
     
    Richard Mueller [MVP], Sep 29, 2009
    #2
    1. Advertisements

  3. Ivan Abramov

    Ivan Abramov Guest

    I changed the last line to:

    Set objWMIService = objSWbemLocator.ConnectServer(sComputer, "root\cimv2",
    sComputer & "\" & sUser, sPassword)

    and tried with many remote computers. It's ok with Win2003Server only.
    But with WinXP the result is the same: 'Access denied' error or 'The RPC
    srver is unavailable' error (on two different comps).
    I tried to turn on many services (concerned with WMI and not), but didn't
    succeed.
    What's wrong with WinXP?
    I've been with this unsolved problem for half a year. Help, plz.
     
    Ivan Abramov, Sep 30, 2009
    #3
  4. Ivan Abramov

    jford Guest

    What WMI property are you querying, and does the local account you are
    specifying have the permissions to perform the query?
     
    jford, Sep 30, 2009
    #4
  5. Ivan Abramov

    Ivan Abramov Guest

    I'm using many of the WMI properties (conserning the computer's config) but
    further.
    Now I cannot accomplish the ConnectServer method (to use the WMI properties).
    I tried both the adminstrator's account and remote user account (which is
    also a member of the administrators group).
     
    Ivan Abramov, Sep 30, 2009
    #5
  6. Ivan Abramov

    Ivan Abramov Guest

    What is wrong with WindowsXP indeed?
     
    Ivan Abramov, Nov 9, 2009
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.