Access Denied Querying with WMI

Posted on 2009-04-27
Last Modified: 2012-05-06
Hi Experts out there!!
I am trying to access the network adapters using WMI. I am trying with the code below. I get access denied on the "scope.connect"-line.  Any ideas? I am creating a Windows application
Dim mgmtOptions As New ConnectionOptions

        mgmtOptions.Impersonation = ImpersonationLevel.Impersonate

        mgmtOptions.Authentication = AuthenticationLevel.Connect

        Dim scope = New ManagementScope("\\" + RemotePC + "\root\cimV2", mgmtOptions)


        Dim QueryNIC As ObjectQuery

        QueryNIC = New ObjectQuery("SELECT * FROM Win32_NetworkAdapter")

        Dim NICSearcher As New ManagementObjectSearcher(scope, QueryNIC)

        Dim Queried As ManagementObject

        For Each Queried In NICSearcher.Get()






Open in new window

Question by:Leif753
    LVL 13

    Accepted Solution


    good morning!
    make sure you have the administrative rights to do so...


    Author Comment

    hehe, much embarrassing. I used wrong account.

    However I got another problem. I the error:"The application called an interface that was marshalled for a different thread."  on this line: For Each Queried In NICSearcher.Get()

    And I am not using several threads

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now