本帖最后由 pcl_test 于 2018-3-28 05:36 编辑
请教一个很小白的问题- echo netsh i i show in>>temp.bat
- echo ^@set /p idx=请输入“本地连接”的Idx编号:>>temp.bat
- echo netsh interface ipv4 set dns name=^%idx^% static 192.168.1.230 >>temp.bat
- echo netsh interface ipv4 add dns name=^%idx^% 192.168.1.223 index=2 >>temp.bat
- echo ping 127.1 -n 3 >null>>temp.bat
复制代码 运行后的结果是:
netsh i i show in
@set /p idx=请输入“本地连接”的Idx编号:
netsh interface ipv4 set dns name= static 192.168.1.230
netsh interface ipv4 add dns name= 192.168.1.223 index=2
ping 127.1 -n 3
可是我需要的运行结果是:
netsh i i show in
@set /p idx=请输入“本地连接”的Idx编号:
netsh interface ipv4 set dns name=%idx% static 192.168.1.230
netsh interface ipv4 add dns name=%idx% 192.168.1.223 index=2
ping 127.1 -n 3
我单独把第三和第四句在dos下运行,运行结果是我需要的结果。可是为什么组合到一起却不是我想得到的结果? |