(view source code of login_log_ip_mac_wmic.bat as plain text)
SETLOCAL ENABLEDELAYEDEXPANSION
SET WMIPath=Path Win32_NetworkAdapter
SET WMIQuery=WHERE "AdapterType LIKE 'Ethernet%%' AND MACAddress > '' AND NOT PNPDeviceID LIKE 'ROOT\\%%'"
FOR /F "tokens=*" %%A IN ('WMIC %WMIPath% %WMIQuery% Get MACAddress /Format:List ^| FIND "="') DO SET %%A
SET WMIPath=Path Win32_NetworkAdapterConfiguration
SET WMIQuery=WHERE "MACAddress='%%MACAddress%%'"
FOR /F "tokens=*" %%A IN ('WMIC %WMIPath% %WMIQuery% Get IPAddress /Format:List ^| FIND "="') DO (
FOR /F "tokens=2 delims==" %%B IN ("%%~A") DO (
IF NOT "%%~B"=="" (
FOR /F "tokens=1 delims={}" %%C IN ("%%~B") DO (
SET IPAddress=!IPAddress!,%%~C
)
)
)
)
>> \\Server\Logs\%Today%\%UserName%.log ECHO.%IPAddress:~1%,%MACAddress::=%
ENDLOCAL
page last modified: 2024-04-16; loaded in 0.0042 seconds