Displaying computer name
Posted: 29 Oct 2010 13:11
I am trying to write a script to display a computers name if the IP Address is entered. I cant get the code to display it correctly. Currently this is what I have....
for /f "tokens=2 delims=g[" %%a in ('ping -a %ipaddress% ^|find "Pinging"') do echo Current Computer Name / IP: %ipaddress% / %%a
When run it should display it as:
"ipaddress / computername"
What I want is for it to display what is between the word Pinging and the [ symbol. the problem is there is more than one g in the line so the code does not work correctly.
Any thoughts?
for /f "tokens=2 delims=g[" %%a in ('ping -a %ipaddress% ^|find "Pinging"') do echo Current Computer Name / IP: %ipaddress% / %%a
When run it should display it as:
"ipaddress / computername"
What I want is for it to display what is between the word Pinging and the [ symbol. the problem is there is more than one g in the line so the code does not work correctly.
Any thoughts?