16 April 2009

Find MAC Address (GetMac)

GetMAC provides a quick method for obtaining the MAC (Ethernet) layer address. I've created a small script that rerurens a MAC address (Without delimeter). Here is a content of mac.bat:

@Echo off
SETLOCAL
SET MAC=
SET Media=Connected

FOR /F "Tokens=3 Delims= " %%a in ('getmac^|find "Media"') do set Media=%%a

IF /I %Media% == disconnected (
FOR /F "Tokens=1-6 Delims=- " %%a in ('getmac^|find "Media"') do set MAC=%%a%%b%%c%%d%%e%%f
)

IF NOT %Media% == disconnected (
FOR /F "Tokens=1-6 Delims=- " %%a in ('getmac^|find "Device\Tcpip_"') do set MAC=%%a%%b%%c%%d%%e%%f
)

@echo %MAC%
ENDLOCAL

Bookmark and Share ITStuff.ca

No comments:

Post a Comment