Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:scriptsamples:macaddress [2015/09/14] (current)
Line 1: Line 1:
 +====== How To: Obtain the Physical Address of a Computer ======
 +====== RhinoScript ======
 +> **Summary:​** //​Illustrates [[developer:​rhinoscript|RhinoScript]] code that determines the physical, or MAC, address of a computer.//
 +
 +The following [[developer:​rhinoscript|RhinoScript]] uses the Windows Management Instrumentation (WMI) to determine the physical addresses, or MAC addresses, of a computer.
 +
 +
 +<code vb>
 + 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
 +
 +
 +</​code>​
 +
 +
 +{{tag>​Developer RhinoScript}}
  
developer/scriptsamples/macaddress.txt ยท Last modified: 2015/09/14 (external edit)