Re: DHCP and VBScripting
- From: "James Whitlow" <jwhitlow@xxxxxxxxxx>
- Date: Thu, 14 Jul 2005 12:02:10 -0500
"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
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.
- Follow-Ups:
- Re: DHCP and VBScripting
- From: James Tee Stain
- Re: DHCP and VBScripting
- References:
- DHCP and VBScripting
- From: James Tee Stain
- Re: DHCP and VBScripting
- From: Marty List
- Re: DHCP and VBScripting
- From: James Tee Stain
- DHCP and VBScripting
- Prev by Date: Re: Win32_ComputerSystem
- Next by Date: Re: Script to delete files
- Previous by thread: Re: DHCP and VBScripting
- Next by thread: Re: DHCP and VBScripting
- Index(es):
Relevant Pages
|