Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Access Denied Querying with WMI

Posted on 2009-04-27
3
Medium Priority
?
972 Views
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)
        scope.connect()
 
        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()
            Debug.Print(Queried!ProductName)
            Debug.Print(Queried!Name)
            Debug.Print(Queried!Index)
            Debug.Print(Queried!NetConnectionID)
        Next

Open in new window

0
Comment
Question by:Leif753
2 Comments
 
LVL 13

Accepted Solution

by:
game-master earned 1000 total points
ID: 24246955


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



game-master
0
 

Author Comment

by:Leif753
ID: 24248437
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
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

571 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