我已經批量編寫了幾條命令,可以在選擇的基礎上執行它們。我使用2個IP地址,每次在IP之間切換時都必須更改IPv4和DNS。批量更改IP和DNS的命令
我已經完成了這段代碼,如果我一行一行地執行但是在批處理中他們給出了錯誤,這個工作正常。
@ECHO OFF
SET /P no= Welcome dude so what are you up to press 1 for buzznet,2 for BSNL :
IF "%NO%"=="1" GOTO BUZZ
IF "%NO%"=="2" GOTO BSNL
:BUZZ
netsh interface ipv4 set address name="Ethernet" source=static^
addr=192.168.22.19 mask=255.255.255.0 gateway=192.168.22.1
netsh interface ip add dns name="Ethernet" addr=192.168.18.1
netsh interface ip add dns name="Ethernet" addr=8.8.8.8 index=2
:BSNL
netsh interface ip set address "Ethernet" dhcp
netsh interface ip set dns 「Ethernet」 dhcp
pause
你會得到什麼樣的錯誤? – TDG
更正的語法。 – Chuck
使用變量與周圍'%'(在開始和結束時)'%NO'沒有意義,它應該是'%NO%'。刪除'@echo off'來查看哪一行正在生成錯誤消息。 – Stephan