zelles Posted November 1, 2014 Posted November 1, 2014 (edited) 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 Edited November 1, 2014 by zelles WannaBeGut and Ascer 2
stealthmsgr Posted November 3, 2014 Posted November 3, 2014 This could prove to be very handy. Thanks for sharing.
funkey Posted November 3, 2014 Posted November 3, 2014 I used this function in a small tool, to get the MAC from IP and the vendor name from MAC. Tool is called Ip2Mac&Vendor and can be found on german AutoIt forum: http://autoit.de/index.php/Thread/45340-Offline-IP-zu-MAC-und-Hersteller-Konverter/ Download: http://autoit.de/index.php/Attachment/24512-IP2Mac-Vendor-7z/ Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning.
magicsign Posted May 15, 2020 Posted May 15, 2020 Easier way (just change "Ethernet Connection" with whatever info you are looking for mac addr.) : Local $pid = Run(@ComSpec & " /c " & 'getmac /fo csv /v | find "Ethernet Connection"','',@SW_HIDE,$STDOUT_CHILD); ProcessWaitClose($pid) Local $sOutput = StdoutRead($pid) ConsoleWrite($sOutput)
RelaaX Posted March 25, 2023 Posted March 25, 2023 pretty cool. What if i have 3 different MAC adresses and want to get first or second? Script gives me 3rd (last)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now