I have Windows 7 machines that get imaged, and after imaging I have to set the environment variable STATION to the last octet of the machine's IP address. How would I parse the IP address and grab the last octet to set the STATION variable?
This only sets the variable to the full ip address:
@echo off
for /f "tokens=1 delims=:" %%j in ('ping %computername% -4 -n 1 ^| findstr Reply') do (set localip=%%j)
SETX /m STATION "%localip:~11%"