我想写一批处理:先ping 一个网址后将得到的ip地址读出来,并写入到hosts文件中去,可是遇到问题了,如下
@echo off
ping www.163.com -n 1 >a.txt
for /f "delims=[ tokens=2" %%i in (a.txt) do set b=%%i
for /f "delims=] tokens=1" %%a in ("%b%") do echo %%a >c:\hosts
echo www.163.com >>c:\hosts
del /f /s /q C:\WINDOWS\system32\drivers\etc\hosts && copy c:\host C:\WINDOWS\system32\drivers\etc