A. You can enumerate a machine's list of network adapters and find the associated MAC address. The following sample code, which you can download here, prints out the network adapter name and the MAC address.
Dim objNetworkAdapters, objAdapter, objWMI Set objWMI = Nothing Set objWMI = GetObject("winmgmts:") ' Get a list of IP-enabled adapters. Set objNetworkAdapters = objWMI.ExecQuery("select * from Win32_NetworkAdapterConfiguration where IPEnabled = 1") For Each objAdapter In objNetworkAdapters wscript.echo "Network adapter: " & objAdapter.Caption & " has MAC address " & objAdapter.MacAddress Next
Here's a sample execution showing two adapters on the machine: D:\temp>cscript getmac.vbs Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. Network adapter: \[00000009\] Broadcom 570x Gigabit Integrated Controller has MAC address 00:0F:1F:25:DC:76 Network adapter: \[00000014\] Intel(R) PRO/Wireless 2200BG Network Connection has MAC address 00:0E:35:6E:2C:B4
0 comments
Hide comments