hamda000
asked on
Get remote pc mac address with vb.net
Hi,
I'm working on a local application that retrieve a network card physical address. Here is my code:
Private Sub frmRemoteMacAddress_Load(B yVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim theNetworkInterfaces() As System.Net.NetworkInformat ion.Networ kInterface = System.Net.NetworkInformat ion.Networ kInterface .GetAllNet workInterf aces()
For Each currentInterface As System.Net.NetworkInformat ion.Networ kInterface In theNetworkInterfaces
If currentInterface.Operation alStatus = Net.NetworkInformation.Ope rationalSt atus.Up And currentInterface.NetworkIn terfaceTyp e.ToString () = "Ethernet" Then
lblRequestedMacAddress.Tex t = currentInterface.GetPhysic alAddress( ).ToString ()
' lblNicModel.Text = currentInterface.Descripti on.ToStrin g()
End If
Next
End Sub
Therefor, this code retrieve only the local mac address.
Can anyone correct me please?
Thanks.
I'm working on a local application that retrieve a network card physical address. Here is my code:
Private Sub frmRemoteMacAddress_Load(B
Dim theNetworkInterfaces() As System.Net.NetworkInformat
For Each currentInterface As System.Net.NetworkInformat
If currentInterface.Operation
lblRequestedMacAddress.Tex
' lblNicModel.Text = currentInterface.Descripti
End If
Next
End Sub
Therefor, this code retrieve only the local mac address.
Can anyone correct me please?
Thanks.
ASKER
Hi,
Thanks for the answer.
first the following statement has error:
Dim tq as new string = "SELECT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = 1"
The error is: end of statement expected.
Dim toq As New ObjectQuery(tq):
Error: tq is not declared.
We should may be write it this way:
Dim tq as new string( "SELECT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = 1")
NO error
Second error in this line:
For Each cr As ManagementObject In trc
trc is underlined and have this statement:
Expression is of type 'RemoteComputerInfos.Manag ementObjec tCollectio n' which is not collection type.
Please take note that RemoteComputerInfos is the name of my application (Solution).
Thanks for correcting or submitting new items. I'm still working on.
Thanks for the answer.
first the following statement has error:
Dim tq as new string = "SELECT * FROM Win32_NetworkAdapterConfig
The error is: end of statement expected.
Dim toq As New ObjectQuery(tq):
Error: tq is not declared.
We should may be write it this way:
Dim tq as new string( "SELECT * FROM Win32_NetworkAdapterConfig
NO error
Second error in this line:
For Each cr As ManagementObject In trc
trc is underlined and have this statement:
Expression is of type 'RemoteComputerInfos.Manag
Please take note that RemoteComputerInfos is the name of my application (Solution).
Thanks for correcting or submitting new items. I'm still working on.
Have you added
Imports System.Management
at the top and added reference to it as well?
Imports System.Management
at the top and added reference to it as well?
ASKER
Yes I did.
ahh ok sorry for taking so long but here is the way to fix it use the following edited code and follow the instructions at the bottom
Dim tm As New ManagementScope("\\" & ComputerName & "\root\cimv2")
Dim tq As String = "SELECT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = 1"
Dim toq As New ObjectQuery(tq)
Dim ts As New ManagementObjectSearcher(t m, toq)
Dim trc As ManagementObjectCollection = ts.get()
For Each cr As ManagementObject In trc
MessageBox.Show(cr("MacAdd ress").ToS tring())
Next
right click on references in solution explorer go to add reference and add System.Management.dll and System.Management.Instrume ntation.dl l into the project.
and then try again :)
Dim tm As New ManagementScope("\\" & ComputerName & "\root\cimv2")
Dim tq As String = "SELECT * FROM Win32_NetworkAdapterConfig
Dim toq As New ObjectQuery(tq)
Dim ts As New ManagementObjectSearcher(t
Dim trc As ManagementObjectCollection
For Each cr As ManagementObject In trc
MessageBox.Show(cr("MacAdd
Next
right click on references in solution explorer go to add reference and add System.Management.dll and System.Management.Instrume
and then try again :)
ASKER
Thank you.
Therefore I right click or double click on the My project (I am on VS 2010), I'm on the references tab, I choose the .com where are stored the .dll files and I click on Add but in the references list there are no System.Management.dll or System.Management.Instrume ntation.dl l
Sorry and thanks anyway
Therefore I right click or double click on the My project (I am on VS 2010), I'm on the references tab, I choose the .com where are stored the .dll files and I click on Add but in the references list there are no System.Management.dll or System.Management.Instrume
Sorry and thanks anyway
for the affore mentioned dlls are located in .NET not .COM
sorry for not pointing this out to start
DLH
sorry for not pointing this out to start
DLH
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI everyone,
Sorry but all solutions displayed are did not fix my project. Please find attached a .sln file including my project. Some words are in french but I know you undrstand. If you need more files just let me know or tell me how I can upload the whole project.
Thanks.
Remote-Computer-Infos.vb
Sorry but all solutions displayed are did not fix my project. Please find attached a .sln file including my project. Some words are in french but I know you undrstand. If you need more files just let me know or tell me how I can upload the whole project.
Thanks.
Remote-Computer-Infos.vb
ASKER
thanks.
to use this code you need to import System.Management and System.Management.Instrume
what it does is sends a request to a remote network computer to get the info
if its over the internet your wanting to do this then i would need to do some more looking
let me know if this helps
D.L.H.
Open in new window