1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 | 'Retrieve Your Computer's MAC Address(es)
'获取所有mac,无论是否已经连接
intCount = 0
strMAC = ""
' We're interested in MAC addresses of physical adapters only
strQuery = "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID > ''"
Set objWMIService = GetObject( "winmgmts://./root/CIMV2" )
Set colItems = objWMIService.ExecQuery( strQuery, "WQL", 48 )
For Each objItem In colItems
If InStr( strMAC, objItem.MACAddress ) = 0 Then
strMAC = strMAC & "," & objItem.MACAddress
intCount = intCount + 1
End If
Next
' Remove leading comma
If intCount > 0 Then strMAC = Mid( strMAC, 2 )
Select Case intCount
Case 0
WScript.Echo "No MAC Addresses were found"
Case 1
WScript.Echo "MAC Address: " & strMAC
Case Else
WScript.Echo "MAC Addresses: " & strMAC
End Select
|