Re: DHCP and VBScripting



"James Tee Stain" <Cobalt_blueuk@xxxxxxxxx> wrote in message
news:c6vBe.152668$Vj3.53035@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> VBScript is ideal, as I'm only needing a read only program, Type in the IP
> address and extract the MAC address.

If you are just looking for a quick way to get a MAC address for a
particular IP address, consider combining PING with ARP:

ping -n 1 -w 250 10.1.1.1>NUL: && arp -a 10.1.1.1

You can wrap a VBScript around this:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim IP, MAC, oExec, RegEx, WSH, x
Set RegEx = New RegExp
Set WSH = CreateObject("WScript.Shell")

If InStr(1, WScript.FullName, "wscript", 1) Then
WSH.Run "cscript.exe " & WScript.ScriptFullName, 0, False
WScript.Quit
End If

IP = InputBox("Type the IP Address")
RegEx.Pattern = "^.*(([0-9a-fA-F]{2}-){5}[0-9a-fA-F]{2}).*$"

If Len(IP) = 0 Then WScript.Quit

Set oExec = WSH.Exec("%comspec% /c ping -n 1 -w 250 " _
& IP & ">NUL:&&arp -a " & IP)

Do While oExec.Status = 0
WScript.Sleep 100
Loop

Do Until oExec.StdOut.AtEndOfStream
x = oExec.StdOut.ReadLine
If RegEx.Test(x) Then MAC = RegEx.Replace(x, "$1")
Loop

If Not RegEx.Test(MAC) Or oExec.ExitCode Then
MAC = "MAC Address not found."
End If

MsgBox MAC
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


.



Relevant Pages

  • Re: DHCP and VBScripting
    ... >> VBScript is ideal, as I'm only needing a read only program, Type in the ... >> address and extract the MAC address. ... all printers attached to the their network. ... full audit we need the IP/MAC addresses from the DHCP server as well to ...
    (microsoft.public.scripting.vbscript)
  • Re: macintosh question
    ... You can run a vbscript from an XP system on the same network and get *some* ... To get the rest would likely require the MAC to be running ... "Al Dunbar" wrote: ...
    (microsoft.public.scripting.vbscript)
  • Re: Can Macintosh users able to access ASP.NET 2.0 site?
    ... If I don't use Client side Vbscript and Activex control, ... compatible with IE5.0 browser on Mac OS. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Compare two text streams
    ... outer loop to reopen it each time the loop executes. ... files with mac addresses. ... Set objFSO = CreateObject ... Set objTextStream1 = objFSO.OpenTextFile ...
    (microsoft.public.scripting.vbscript)
  • Re: Ruby is Running Slow on Mac OS X
    ... My mac is new, ... I have it on a loop, and on average it took 10-30 ... One thing I observed on upgrading to Leopard (see ... use WPA instead of WEP encryption. ...
    (comp.lang.ruby)