本帖最后由 wd4455 于 2016-7-11 10:43 编辑
回复 19# pcl_test
不好意思了大神,小弟愚钝,研究了很久变量的连续赋值没弄明白最后使用了- @echo off&setlocal enabledelayedexpansion
- for /f "tokens=1* delims==" %%a in ('wmic nic where "PNPDeviceID like 'pci\\%%' or PNPDeviceID like 'usb\\%%'" get NetConnectionID /value^|find "="') do set /a n+=1&set "#!n!=%%b"
- if defined #1 (goto:#1) else (goto:结束)
- :#1
- netsh interface ip set dns name="%#1%" source=static addr=202.96.199.132
- netsh interface ip add dns "%#1%" 202.96.64.38 index=2
-
- if defined #2 (goto:#2) else (goto:结束)
- :#2
- netsh interface ip set dns name="%#2%" source=static addr=202.96.199.132
- netsh interface ip add dns "%#2%" 202.96.64.38 index=2
- if defined #3 (goto:#3) else (goto:结束)
- :#3
- netsh interface ip set dns name="%#3%" source=static addr=202.96.199.132
- netsh interface ip add dns "%#3%" 202.96.64.38 index=2
- if defined #4 (goto:#4) else (goto:结束)
- :#4
- netsh interface ip set dns name="%#4%" source=static addr=202.96.199.132
- netsh interface ip add dns "%#4%" 202.96.64.38 index=2
- if defined #5 (goto:#5) else (goto:结束)
- :#5
- netsh interface ip set dns name="%#5%" source=static addr=202.96.199.132
- netsh interface ip add dns "%#5%" 202.96.64.38 index=2
- :结束
- exit
复制代码 的办法绕开赋值。。。 不好意思有被教导了 |