cinnabon Posted August 29, 2012 Share Posted August 29, 2012 Hi, hope someone can help a newbie on AutoIt, i know a remote Client LAN IP but not its MAC. $RemClientIP = 192.168.1.50 manually i would just open CMD and do this: --------------------- C:\Windows\System32>arp -a 192.168.1.50 Schnittstelle: 192.168.1.20 --- 0xd Internetadresse Physische Adresse Typ 192.168.1.50 40-AB-40-AB-40-AB dynamisch ---------------------- I can put the output of the CMD into $ip2mac: $ip2mac = Run(@ComSpec & " /c " & 'arp -a ' & $RemClientIP, "", @SW_HIDE, $STDOUT_CHILD) I cant find a way to get the RemoteClientMAC (40-AB-....) Wich way to go? Because this might explain me, how to generally handle input. Greetz Marco Link to comment Share on other sites More sharing options...
hannes08 Posted August 29, 2012 Share Posted August 29, 2012 Hello Marco,you can use StdOutRead() in your script to read the output of your command into a variable.Then you can use StringSplit to split your output into lines for example.Lastly you use StringSplit again to split the last line into IP, MAC and what folows.You can also use Regular Expressions but I still have not enough experience to help you there. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 29, 2012 Moderators Share Posted August 29, 2012 Hi, cinnabon, welcome to the forum. Try something like this: $PC = InputBox("Remote MAC", "Enter the name of the computer to get the MAC address") $WMI = ObjGet("winmgmts:" & $PC & "rootcimv2") $query = $WMI.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") For $element in $query MsgBox(0, "", $element.MACAddress) Next "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
cinnabon Posted August 29, 2012 Author Share Posted August 29, 2012 :idiot: :idiot: :idiot: #include <Constants.au3> Local $RemoteClientIP = "192.168.1.50" Local $RemoteClientMAC = Run(@ComSpec & " /c " & 'arp -a ' & $RemoteClientIP, @SystemDir, @SW_HIDE, $STDOUT_CHILD) Local $line While 1 $line = StdoutRead($RemoteClientMAC) If @error Then ExitLoop If $line Then Local $array = StringSplit($line, @CRLF, 1) ; Splitt input by Linebreaks $line4 = StringSplit($array[4], " ",1) ; splitting Line 4 into peaces local $RemoteClientIParray = StringSplit($RemoteClientIP, ".") if $RemoteClientIParray[4] >= 100 Then ; if 4th Octett is 100 or bigger MsgBox(0, $RemoteClientIP, $line4[12]) ; MAC is in Array 12 Else ; if 4th Octett is 99 or smaller MsgBox(0, $RemoteClientIP, $line4[13]) ; MAC is in Array 13 EndIf EndIf WEnd IT WORX THX 100 times. Greetz Marco Link to comment Share on other sites More sharing options...
cinnabon Posted August 29, 2012 Author Share Posted August 29, 2012 (edited) I played a little around and i have to say i like this stringthingies: i did something different to understand. While 1 Local $ipconfigall = StdoutRead(Run(@ComSpec & " /c " & 'ipconfig /all', @SystemDir, @SW_HIDE, $STDOUT_CHILD)) if @error then ExitLoop if $ipconfigall Then Local $ipconfig_split = StringSplit($ipconfigall, @CR, 1) ; Breaks consoleinput into LINES Local $myHostname = StringSplit($ipconfig_split[4], ":", 1) ; enter Linenumber that needs to read MsgBox(0,"","Hostname: " & $myHostname[2]) ; 2nd Block is what we're looking for Local $myMAC = StringSplit($ipconfig_split[14], ":", 1) ; enter Linenumber that needs to read MsgBox(0,"","Mac: " & $myMAC[2]) ExitLoop EndIf WEnd THX FOR THE HELP Edited August 29, 2012 by cinnabon Link to comment Share on other sites More sharing options...
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