新聞中心
本文通過BAT腳本,實現(xiàn)在WIN7上設(shè)置IP等網(wǎng)絡(luò)信息,以下是示例:

以下是腳本:
@?echo?off
%1?%2
ver|find?"5.">nul&&goto?:st
mshta?vbscript:createobject("shell.application").shellexecute("%~s0","goto?:st","","runas",1)(window.close)&goto?:eof
:st
echo/
title?修改本機IP地址
color?1f
echo?*****************************************************************
echo?*???????????????????????????????????????????????????????????????*
echo?*????????????????????修改本機網(wǎng)卡IP地址?????????????????????????*
echo?*????????????????????????1.靜態(tài)地址?????????????????????????????*
echo?*????????????????????????2.自動獲取?????????????????????????????*
echo?*****************************************************************
:begin
set?/p?n=請輸入要設(shè)置的網(wǎng)卡類型(1或2):
if?"%n%"?lss?"1"?echo?您輸入的網(wǎng)卡不存在!請重新輸入?。?!
if?"%n%"?gtr?"2"?echo?您輸入的網(wǎng)卡不存在!請重新輸入?。?!
echo/
if?"%n%"?lss?"1"?goto?begin
if?"%n%"?gtr?"2"?goto?begin
if?"%n%"?equ?"1"?goto?x1
if?"%n%"?equ?"2"?goto?x2
:x1
echo?您選擇的是:%n%.以太網(wǎng)
:begin1
set?/p?a=??請輸入靜態(tài)IP地址(如?192.168.1.2):
if?"%a%"?equ?""?goto?begin1
:begin2
set?/p?b=??請輸入子網(wǎng)掩碼(如?255.255.255.0):
if?"%b%"?equ?""?goto?begin2
:begin3
set?/p?c=??請輸入網(wǎng)關(guān)地址(如?192.168.1.1):
if?"%c%"?equ?""?goto?begin3
:begin4
set?/p?d=??請輸入DNS地址1(如?114.114.114.114):
if?"%d%"?equ?""?goto?begin4
:begin5
set?/p?e=??請輸入DNS地址2(如?211.138.156.66):
if?"%e%"?equ?""?goto?begin5
:begin6
set?/p?f=??請輸入WINS地址(如?8.8.8.8):
if?"%f%"?equ?""?goto?begin6
netsh?interface?ip?set?address?"本地連接"?static?%a%?%b%?%c%
netsh?interface?ip?set?dns?"本地連接"?static?%d%?primary>nul
netsh?interface?ip?add?dns?"本地連接"?%e%>nul
netsh?interface?ip?set?wins?"本地連接"?static?%f%>nul
echo??靜態(tài)地址設(shè)置成功!!!
ping?-n?5?127.0.0.1>nul
goto:eof
:x2
echo?選擇的是:%n%.自動獲取
echo?*******************************************************
echo?*????????IP即將初始化為自動獲取狀態(tài)……?????????????????*
netsh?interface?ip?set?address?"本地連接"?dhcp>nul
netsh?interface?ip?set?dns?"本地連接"?dhcp>nul
echo?*******************************************************
echo?DHCP設(shè)置成功!!!
ping?-n?5?127.0.0.1>nul
goto:eof
pause
分享題目:windows通過BAT腳本設(shè)置IP、DNS
當(dāng)前URL:http://fisionsoft.com.cn/article/cochedo.html


咨詢
建站咨詢
