(view source code of getmacxp.bat as plain text)
@ECHO OFF
:: Check OS versionIF NOT "%OS%"=="Windows_NT" GOTO Syntax
SETLOCAL
:: Check command line argumentsIF NOT "%~2"=="" GOTO Syntax
ECHO.%1 | FINDSTR /R /C:"[/?*]" >NUL && GOTO Syntax
:: If the batch file is intended for use on:: local computers only, remove the next line:IF "%~1"=="" (SET Computer=%ComputerName%) ELSE (SET Computer=%~1)
:: The actual command is a one-liner, be it a long one.:: If the batch file is intended for use on local computers only,:: use IPCONFIG /ALL instead of NBTSTAT -a %Computer%FOR /F "tokens=*" %%A IN ('NBTSTAT -a %Computer% 2^>NUL ^| FINDSTR /R /I /C:"[0-9A-F][0-9A-F]-*[0-9A-F][0-9A-F]-*[0-9A-F][0-9A-F]-*[0-9A-F][0-9A-F]-*[0-9A-F][0-9A-F]-*[0-9A-F][0-9A-F]"') DO FOR %%B IN (%%A) DO SET MACAddress=%%B
:: Show result and exitECHO MAC Addres of %Computer%: %MACAddress%
ENDLOCAL & SET MACAddress=%MACAddress%
GOTO:EOF
:SyntaxECHO.
ECHO GetMacXP.bat, Version 1.00 for Windows NT 4 and later
ECHO Show the MAC address for any computer in the workgroup or domain
ECHO.
ECHO Usage: GETMACXP [ computer ]
ECHO.
ECHO Where: "computer" is the name of the computer we want to know the
ECHO MAC address of (default is the local computer)
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
IF "%OS%"=="Windows_NT" ENDLOCAL
page last modified: 2025-10-11; loaded in 0.0068 seconds