Use the CD command along FOR to retrieve current path, output only the folder name and ping it.
Test.bat:
@echo off FOR /F %%i IN ('cd') DO set ADDRESS=%%~nxi ping %ADDRESS%
Result:
C:\Users\Aybe\127.0.0.1>test.bat Pinging 127.0.0.1 with 32 bytes of data: Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Ping statistics for 127.0.0.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms C:\Users\Aybe\127.0.0.1>
Another example:
C:\Users\Aybe\yahoo.com>test Pinging yahoo.com [98.139.183.24] with 32 bytes of data: Reply from 98.139.183.24: bytes=32 time=116ms TTL=48 Reply from 98.139.183.24: bytes=32 time=120ms TTL=48 Reply from 98.139.183.24: bytes=32 time=116ms TTL=48 Reply from 98.139.183.24: bytes=32 time=119ms TTL=48 Ping statistics for 98.139.183.24: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 116ms, Maximum = 120ms, Average = 117ms C:\Users\Aybe\yahoo.com>