Results 1 to 3 of 3

Thread: Read registry on remote computer (with alternate credentials)

  1. #1
    Jo Guest

    Read registry on remote computer (with alternate credentials)

    Hello,

    Sorry for my very bad English...

    I have a problem when I tried to read registry on remotes computers.
    The code must run under VBA Excel. The final purpose is to extract
    from print servers the list of installed printers with ip address.
    Remotes servers are on various domains without trusts relationships
    and various OS like W2003, W2K and NT4.

    When I use this code:

    Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    oReg = objSWbemLocator.ConnectServer(strSrvName, "root
    \default:StdRegProv", strDomain & "\" & strUser, strPassword)

    I always receive the error message "The object doesn't support this
    property or method...".

    I have tried this syntax:

    Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    objSWbemServices = objSWbemLocator.ConnectServer(strSrvName, "root
    \default", strDomain & "\" & strUser, strPassword)
    Set oReg = objSWbemServices.Get("StdRegProv")

    with the same effect.

    Thank's for your help.
    Jo

    PS: ConnectServer on other namespace like root\cimv2 works fine for
    other purpose but in same context (domain, servers, user...)




  2. #2
    urkec Guest

    RE: Read registry on remote computer (with alternate credentials)

    "Jo" wrote:

    > Hello,
    >
    > Sorry for my very bad English...
    >
    > I have a problem when I tried to read registry on remotes computers.
    > The code must run under VBA Excel. The final purpose is to extract
    > from print servers the list of installed printers with ip address.
    > Remotes servers are on various domains without trusts relationships
    > and various OS like W2003, W2K and NT4.
    >
    > When I use this code:
    >
    > Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    > oReg = objSWbemLocator.ConnectServer(strSrvName, "root
    > \default:StdRegProv", strDomain & "\" & strUser, strPassword)



    You're missing a Set here, SWbemLocator.ConnectServer returns SWbemServices
    object (even if you include the class name in the namespace path)

    strSrvName = "."

    Set objSWbemLocator = CreateObject _
    ("WbemScripting.SWbemLocator")

    Set oReg = objSWbemLocator.ConnectServer _
    (strSrvName, "root\default:StdRegProv")

    Debug.Print TypeName(oReg)

    Set StdRegProv = oReg.Get("StdRegProv")

    For Each Method In StdRegProv.Methods_
    Debug.Print Method.Name
    Next


    (I was only able to test this locally)


    In the second code snippet you also missed a Set:


    strSrvName = "."

    Set objSWbemLocator = CreateObject _
    ("WbemScripting.SWbemLocator")

    ' Need Set here:
    Set objSWbemServices = objSWbemLocator.ConnectServer _
    (strSrvName, "root\default")

    Set oReg = objSWbemServices.Get("StdRegProv")

    For Each Method In oReg.Methods_
    Debug.Print Method.Name
    Next




    --
    urkec

  3. #3
    Jo Guest

    Re: Read registry on remote computer (with alternate credentials)

    On Sep 26, 10:33 pm, urkec <ur...@discussions.microsoft.com> wrote:
    > "Jo" wrote:
    > > Hello,

    >
    > > Sorry for my very bad English...

    >
    > > I have a problem when I tried to read registry on remotes computers.
    > > The code must run under VBA Excel. The final purpose is to extract
    > > from print servers the list of installed printers with ip address.
    > > Remotes servers are on various domains without trusts relationships
    > > and various OS like W2003, W2K and NT4.

    >
    > > When I use this code:

    >
    > > Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    > > oReg = objSWbemLocator.ConnectServer(strSrvName, "root
    > > \default:StdRegProv", strDomain & "\" & strUser, strPassword)

    >
    > You're missing a Set here, SWbemLocator.ConnectServer returns SWbemServices
    > object (even if you include the class name in the namespace path)
    >
    > strSrvName = "."
    >
    > Set objSWbemLocator = CreateObject _
    > ("WbemScripting.SWbemLocator")
    >
    > Set oReg = objSWbemLocator.ConnectServer _
    > (strSrvName, "root\default:StdRegProv")
    >
    > Debug.Print TypeName(oReg)
    >
    > Set StdRegProv = oReg.Get("StdRegProv")
    >
    > For Each Method In StdRegProv.Methods_
    > Debug.Print Method.Name
    > Next
    >
    > (I was only able to test this locally)
    >
    > In the second code snippet you also missed a Set:
    >
    > strSrvName = "."
    >
    > Set objSWbemLocator = CreateObject _
    > ("WbemScripting.SWbemLocator")
    >
    > ' Need Set here:
    > Set objSWbemServices = objSWbemLocator.ConnectServer _
    > (strSrvName, "root\default")
    >
    > Set oReg = objSWbemServices.Get("StdRegProv")
    >
    > For Each Method In oReg.Methods_
    > Debug.Print Method.Name
    > Next
    >
    > --
    > urkec


    Many Thank's to you.
    Now it work fine.

    Thank's again.
    Jo

Similar Threads

  1. Remote Desktop Connection not using saved credentials
    By Tamas in forum Networking & Security
    Replies: 7
    Last Post: 20-07-2011, 03:22 AM
  2. Replies: 5
    Last Post: 24-12-2010, 02:07 PM
  3. How to read the registry before .NET
    By HarshaB in forum Software Development
    Replies: 4
    Last Post: 29-10-2009, 07:51 AM
  4. Replies: 7
    Last Post: 28-07-2009, 01:24 PM
  5. Replies: 3
    Last Post: 16-01-2008, 10:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,935,642.96495 seconds with 17 queries