GregThompson Posted March 3, 2005 Posted March 3, 2005 (edited) I'm sure someone has made one before, but here is my take on it. You're left with $macaddress as the variable. You will of course need admin rights to run the net config portion, so you can always wrap that RunWait with a RunAs(). Enjoy! RunWait(@ComSpec & " /c net config workstation > " & @TempDir & "\mac.txt", "", @SW_HIDE) If FileExists(@TempDir & "\mac.txt") Then $macfile = FileOpen(@TempDir & "\mac.txt", 0) While 1 $macline = FileReadLine($macfile) If @error = -1 Then ExitLoop $macresult = StringInStr($macline, "NetBT_Tcpip_") If $macresult <> "0" Then $macline = StringStripWS($macline, 4) $macarray = StringSplit($macline, "(") $macline = StringStripWS($macarray[2], 8) $macarray = StringSplit($macline, ")") $macaddress = $macarray[1] ExitLoop EndIf Wend FileClose($macfile) EndIf Edited March 3, 2005 by GregThompson
ter-pierre Posted April 28, 2006 Posted April 28, 2006 My code... RunWait (@ComSpec & ' /c ' & 'nbtstat -A '&@IPAddress1&' | find /I "MAC" >'&@TempDir&'\mac.tmp',@ScriptDir, @SW_HIDE) MsgBox(0,"",StringRight(FileReadLine(@TempDir&'\mac.tmp'),17)) Pierre
AramisResearch Posted July 25, 2006 Posted July 25, 2006 (edited) For what it's worth, the snippet that was posted at the beginning of this thread was probably the most useful and compact bit of code I have found in AutoIT for grabbing the MAC address, but here is what I did to it: Dim $macaddress[4] RunWait(@ComSpec & " /c ipconfig /all > C:\ipconfig.txt", "", @SW_HIDE) If FileExists("C:\ipconfig.txt") Then $nics = 1 $macfile = FileOpen("C:\ipconfig.txt", 0) While $nics < 5 $macline = FileReadLine($macfile) If @error = -1 Then ExitLoop $macresult = StringInStr($macline, "Physical Address") If $macresult <> "0" Then $macline = StringStripWS($macline, 8) $macline = StringTrimLeft($macline, 25) $macarray = StringSplit($macline, "-") $macaddress[$nics] = $macarray[1] & $macarray[2] & $macarray[3] & _ $macarray[4] & $macarray[5] & $macarray[6] MsgBox(0, "MAC Address", $macaddress[$nics]) EndIf Wend FileClose($macfile) EndIf I found I needed the MAC addresses from ALL of the NIC's in a given box so I could use another command line configurator widget to create a NIC team on the fly (Broadcom). It's "hard coded" with the assumption that there are no more than four NIC's in the box. Someone could probably make it even more open ended. -Chris Edited July 25, 2006 by AramisResearch
/dev/null Posted July 25, 2006 Posted July 25, 2006 another one... #include <array.au3> #include <file.au3> $filename = "C:\ipconfig.txt" RunWait(@ComSpec & " /c ipconfig /all > " & $filename , "", @SW_HIDE) Dim $array _FileReadToArray($filename,$array) $text = _ArrayToString($array,";") $macs = StringRegExp($text,":\s((?:\A\A-){5}\A\A);",3) _ArrayDisplay($macs,"MAC Addrs") FileDelete($filename) Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Kondro Posted March 5, 2011 Posted March 5, 2011 For what it's worth, the snippet that was posted at the beginning of this thread was probably the most useful and compact bit of code I have found in AutoIT for grabbing the MAC address, but here is what I did to it: Dim $macaddress[4] RunWait(@ComSpec & " /c ipconfig /all > C:\ipconfig.txt", "", @SW_HIDE) If FileExists("C:\ipconfig.txt") Then $nics = 1 $macfile = FileOpen("C:\ipconfig.txt", 0) While $nics < 5 $macline = FileReadLine($macfile) If @error = -1 Then ExitLoop $macresult = StringInStr($macline, "Physical Address") If $macresult <> "0" Then $macline = StringStripWS($macline, 8) $macline = StringTrimLeft($macline, 25) $macarray = StringSplit($macline, "-") $macaddress[$nics] = $macarray[1] & $macarray[2] & $macarray[3] & _ $macarray[4] & $macarray[5] & $macarray[6] MsgBox(0, "MAC Address", $macaddress[$nics]) EndIf Wend FileClose($macfile) EndIf I found I needed the MAC addresses from ALL of the NIC's in a given box so I could use another command line configurator widget to create a NIC team on the fly (Broadcom). It's "hard coded" with the assumption that there are no more than four NIC's in the box. Someone could probably make it even more open ended. -Chris Nice, I added these to display it in a mesage and copy to clipboard. MsgBox(4096,"My Mac",$macaddress) ClipPut($macaddress)
wraithdu Posted March 5, 2011 Posted March 5, 2011 You're new so, everyone needs time to adjust... but what on earth were you thinking? This thread was 5 YEARS dead, and you brought it back for a MsgBox and a ClipPut? Really?
cramaboule Posted March 5, 2011 Posted March 5, 2011 Hi, my version on my signature :-) My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
andrei0x309 Posted April 10, 2011 Posted April 10, 2011 Anyway since this thread was resurrected , it can be done this way too , and i think is nicer cause is not using the hdd . Func GetEnthPyshAddrs() $Pid = Run(@ComSpec & " /c ipconfig /all", "", 0x0, 0x2) Local $line = "" While 1 $line = StdoutRead($Pid) If StringLen($line) > 0 Then StdioClose($Pid) ExitLoop EndIf WEnd $macs = StringRegExp($line, "[0-9A-F]{2}\-[0-9A-F]{2}\-[0-9A-F]{2}\-[0-9A-F]{2}\-[0-9A-F]{2}", 3) If @error Then Return @error Else Return $macs EndIf EndFunc
Yashied Posted April 10, 2011 Posted April 10, 2011 Also, you can use IPHelper UDF from my sig. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
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