I was trying to get the MAC address of the computer running the script and the most efficient way seams to be using this function. I found it somewhere, but it was broken and would not run at all, and after making some change I got it displaying the Mac address. Does anyone know a more efficient way? This seams pretty efficient. Also, even though it works without issue, did I do things right in the function?
Working function to get the MAC address:
$IP_Address = @IPAddress1
$MAC_Address = GET_MAC($IP_Address)
MsgBox(0, "MAC Address:", $MAC_Address)
Func GET_MAC($_MACsIP)
Local $_MAC,$_MACSize
Local $_MACi,$_MACs,$_MACr,$_MACiIP
$_MAC = DllStructCreate("byte[6]")
$_MACSize = DllStructCreate("int")
DllStructSetData($_MACSize,1,6)
$_MACr = DllCall ("Ws2_32.dll", "int", "inet_addr", "str", $_MACsIP)
$_MACiIP = $_MACr[0]
$_MACr = DllCall ("iphlpapi.dll", "int", "SendARP", "int", $_MACiIP, "int", 0, "ptr", DllStructGetPtr($_MAC), "ptr", DllStructGetPtr($_MACSize))
$_MACs = ""
For $_MACi = 0 To 5
If $_MACi Then $_MACs = $_MACs & ":"
$_MACs = $_MACs & Hex(DllStructGetData($_MAC,1,$_MACi+1),2)
Next
DllClose($_MAC)
DllClose($_MACSize)
Return $_MACs
EndFunc