You could use %COMPUTERNAME%
on Windows.
But it really should not matter, since the packets will never be sent over the network. When you ping the computer's own address – any address, whether loopback or not – Windows recognizes this and loops back the packets inside the OS. It would simply be impractical for it to do otherwise.
On Windows, you can confirm this by reading the route table from route print
– pay attention to the "Gateway" column:
C:\>ipconfig | findstr "Address"
IP Address. . . . . . . . . . . . : 192.168.1.223
IP Address. . . . . . . . . . . . : fe80::202:2dff:fe6b:c71c%6
C:\>route print | findstr "Netmask 127.0.0.1"
Network Destination Netmask Gateway Interface Metric
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.1.223 255.255.255.255 127.0.0.1 127.0.0.1 30
ipconfig /all
runs off the default sizedcmd
window and so you have to scroll up to get what you need. When do thinkping %computername%
would not work?