コンピューターのIPアドレスをスクリプトでキャプチャする方法について、いくつかの驚くべき答えを見つけましたが、すべての答えで、ユーザーはすぐにIPアドレスを出力します。
for /f "tokens=2 delims=[]" %%f in ('ping -4 -n 1 www.google.com ^|find /i "pinging"') do echo IP=%%f
I have a particular need to be able to use the IP Address later in the script. How can I store it in a variable for later use? I would think it would be something line the following:
for /f "tokens=2 delims=[]" %%f in ('ping -4 -n 1 %COMPUTERNAME% ^| find /i "pinging"') do set /A IPADDR=%%f
echo IP: %IPADDR%
When I do this, the variable only contains the first octet. Any help would be appreciated.