Jump to content

Recommended Posts

Posted (edited)

that wont work if you have more subnets thatswhy i use a netbios request

You could:

#include <array.au3>
#include <Constants.au3>
Dim $line
$foo = Run(@ComSpec & " /c nbtstat -a ", "",@SW_Hide, $STDOUT_CHILD)
$count = 1
While 1
    $line &= StdoutRead($foo) & @CRLF
    If @error Then ExitLoop
    $count +=1
Wend

MsgBox (0, "", $line)

I still don't get the MAC Address with the CMD...

EDIT: Missed a bit...

Edited by Bert
Posted (edited)

if i use that i get the mac addres, and more information, i only wanna have the mac address number is that possible?

LAN-Verbindung:

Knoten-IP-Adresse: [172.29.28.138] Bereichskennung: []

NetBIOS-Namentabelle des Remotecomputers

Name Typ Status

---------------------------------------------

UP443 <00> EINDEUTIG Registriert

UP443 <20> EINDEUTIG Registriert

UP443 <03> EINDEUTIG Registriert

up543 <03> EINDEUTIG Registriert

MAC Adresse = 00-0F-1F-E3-6F-43

Edited by realkiller
Posted

This should show you how it is done. And it should get you on your merry way :)

#include <array.au3>
$output = "LAN-Verbindung:" & @LF & _
"Knoten-IP-Adresse: [172.29.28.138] Bereichskennung: []" & @LF & _
@LF & _
@LF & _
@LF & _
"NetBIOS-Namentabelle des Remotecomputers" & @LF & _
@LF & _
@LF & _
@LF & _
"Name Typ Status" & @LF & _
@LF & _
"---------------------------------------------" & @LF & _
@LF & _
"UP443 <00> EINDEUTIG Registriert" & @LF & _
"UP443 <20> EINDEUTIG Registriert" & @LF & _
"UP443 <03> EINDEUTIG Registriert" & @LF & _
@LF & _
"up543 <03> EINDEUTIG Registriert" & @LF & _
@LF & _
@LF & _
@LF & _
"MAC Adresse = 00-0F-1F-E3-6F-43" & @LF

MsgBox (0, "Before Strip all @LF", $output)
$output2 = StringReplace ($output, @LF, "")
MsgBox (0, "After Strip all @LF", $output2)
$output3 = StringSplit ($output2, "MAC Adresse", 1)
_ArrayDisplay ($output3)

$mac = StringReplace ($output3[2], "-", "")
$mac = StringReplace ($mac, "=", "")
$mac = StringReplace ($mac, " ", "")

MsgBox (0, "MAC Address", $mac)
Posted

the problem is it change at every workstation sow i made this but it doesn't filter everything, i need only the mac number

$ip = "up443"
#include <Constants.au3>
Dim $line
$foo = Run(@ComSpec & " /c nbtstat -a "&$ip, "",@SW_Hide, $STDOUT_CHILD)
$count = 1
While 1
    $line &= StdoutRead($foo) & @CRLF
    If @error Then ExitLoop
    $count +=1
Wend
$output2 = StringReplace ($line, @LF, $line)
$output3 = StringSplit ($output2, "MAC Adresse", 1)
$mac = StringReplace ($output3[2], "-", "")
$mac = StringReplace ($mac, "=", "")
$mac = StringReplace ($mac, " ", "")
MsgBox (0, "MAC Address", $mac)
Posted (edited)

Local $arComputers[3] = ["Lab-4", "Lab-5", "Lab-6"]

For $strComputer In $arComputers
    $line = ''
    $PID = Run(@ComSpec & " /c nbtstat -a " & $strComputer,@SystemDir, @SW_HIDE, 2)
    While Not @error
        $line &= StdoutRead($PID)
    WEnd

    If StringInStr($line, "MAC Address = ") Then
        $Mac = StringMid($line, StringInStr($line, "MAC Address = ")+StrLen("MAC Address = "),17)
        MsgBox(0, $strComputer, $Mac)
    Else
        MsgBox(0, $strComputer, "Host Offline")
    EndIf
Next

Just make sure you put the computer names you wish to see the Mac addresses for in the beginning array, and this should show a MsgBox of their MAC addresses, if they're online.

Also make sure to change the "MAC Addresss = " in all three places to match what language Windows you have, and all should work out.

Edited by SkinnyWhiteGuy
Posted

The scripts works half the code is correct but it still doesn't show me a mac addres:(

Local $arComputers[3] = ["up443", "up579", "up125"]


For $strComputer In $arComputers
    $line = ''
    $PID = Run(@ComSpec & " /c nbtstat -a " & $strComputer,@SystemDir, @SW_HIDE, 2)
    While Not @error
        $line &= StdoutRead($PID)
    WEnd

    If StringInStr($line, "MAC Address = ") Then
$Mac = StringMid($line, StringInStr($line, "MAC Address = ")+StringLen("MAC Address = "),17)
        MsgBox(0, $strComputer, $Mac)
    Else
        MsgBox(0, $strComputer, "Host Offline")
    EndIf
Next
Posted

The scripts works half the code is correct but it still doesn't show me a mac addres:(

Local $arComputers[3] = ["up443", "up579", "up125"]


For $strComputer In $arComputers
    $line = ''
    $PID = Run(@ComSpec & " /c nbtstat -a " & $strComputer,@SystemDir, @SW_HIDE, 2)
    While Not @error
        $line &= StdoutRead($PID)
    WEnd

    If StringInStr($line, "MAC Address = ") Then
$Mac = StringMid($line, StringInStr($line, "MAC Address = ")+StringLen("MAC Address = "),17)
        MsgBox(0, $strComputer, $Mac)
    Else
        MsgBox(0, $strComputer, "Host Offline")
    EndIf
Next

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...