Site Tools


How To: Obtain the Physical Address of a Computer

RhinoScript

Summary: Illustrates RhinoScript code that determines the physical, or MAC, address of a computer.

The following RhinoScript uses the Windows Management Instrumentation (WMI) to determine the physical addresses, or MAC addresses, of a computer.

 Sub PrintMacAddress
 
   Dim strComputer
   strComputer = "."
 
   Dim objWMIService
   Set objWMIService = GetObject("winmgmts:" _
       & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
   Dim colAdaptors
   Set colAdapters = objWMIService.ExecQuery _
       ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
   Dim n
   n = 1
 
   For Each objAdapter In colAdapters
    Rhino.Print 
    Rhino.Print "Network Adapter " & n
    Rhino.Print "  Description: " & objAdapter.Description
    Rhino.Print "  Physical (MAC) address: " & objAdapter.MACAddress
    n = n + 1
   Next
 
 End Sub
developer/scriptsamples/macaddress.txt ยท Last modified: 2015/09/14 (external edit)