Obtain IP

  
by computer name Note: The red part may be modified as needed. YourTestPCname is the name of the computer you need to test. The red part of the number is associated with the ip address of the environment. Copy the following code to the bat file. @echo off set pcName=yourTestPCname ~~~~~~~~~~~~~~~~~(red) ping %pcName% -4 @echo - for /f "tokens=2 delims=[" % %i in ('ping %pcName% -4^| Findstr "%pcName%"') do set ip=%%i set iptmp=%ip:~0,14% set lastchar=%iptmp:~13,1% IF /I "%lastchar%"= ="]" (set iptmp=%ip:~0,13%) @echo ==================ip:%iptmp%====== ========= @echo - pause
Copyright © Windows knowledge All Rights Reserved