windows下使用腳本修改網絡配置

@echo off
set /p input=輸入
set hostip=%input%
netsh interface ip set address "WLAN" static 192.168.2.%hostip% 255.255.255.0 192.168.2.1 1
netsh interface ip set dns "WLAN" static 202.96.128.86 primary
netsh interface ip add dns "WLAN" 202.96.128.86

說明

set /p input=輸入
輸入一個主機位的ip

set hostip=%input%
變量hostip賦值,引用input

netsh interface ip set address "WLAN" static 192.168.2.%hostip% 255.255.255.0 192.168.2.1 1
設置ip地址、子網掩碼、網關、跳躍數
"WLAN” 網卡名稱
%hostip% 引用變量

netsh interface ip set dns "WLAN" static 202.96.128.86 primary
設置主dns

netsh interface ip add dns "WLAN" 202.96.128.86
增加備用dns

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章