意见箱
恒创运营部门将仔细参阅您的意见和建议,必要时将通过预留邮箱与您保持联络。感谢您的支持!
意见/建议
提交建议

windows通过BAT脚本设置IP、DNS、

来源:恒创科技 编辑:恒创科技编辑部
2023-07-05 16:19:55
Windows 通过BAT脚本设置IP、DNS

本文通过BAT脚本,实现在WIN7上设置IP等网络信息,以下是示例:

@echooff
%1%2
ver|find"5.">nul&&goto:st
mshtavbscript:createobject("shell.application").shellexecute("%~s0","goto:st","","runas",1)(window.close)&goto:eof

:st

echo/
title修改本机IP地址
color1f
echo*****************************************************************
echo**
echo*修改本机网卡IP地址*
echo*1.静态地址*
echo*2.自动获取*
echo*****************************************************************
:begin
set/pn=请输入要设置的网卡类型(1或2):
if"%n%"lss"1"echo您输入的网卡不存在!请重新输入!!!
if"%n%"gtr"2"echo您输入的网卡不存在!请重新输入!!!
echo/
if"%n%"lss"1"gotobegin
if"%n%"gtr"2"gotobegin
if"%n%"equ"1"gotox1
if"%n%"equ"2"gotox2

:x1
echo您选择的是:%n%.以太网
:begin1
set/pa=请输入静态IP地址(如192.168.1.2):
if"%a%"equ""gotobegin1
:begin2
set/pb=请输入子网掩码(如255.255.255.0):
if"%b%"equ""gotobegin2
:begin3
set/pc=请输入网关地址(如192.168.1.1):
if"%c%"equ""gotobegin3
:begin4
set/pd=请输入DNS地址1(如114.114.114.114):
if"%d%"equ""gotobegin4
:begin5
set/pe=请输入DNS地址2(如211.138.156.66):
if"%e%"equ""gotobegin5
:begin6
set/pf=请输入WINS地址(如8.8.8.8):
if"%f%"equ""gotobegin6
netshinterfaceipsetaddress"本地连接"static%a%%b%%c%
netshinterfaceipsetdns"本地连接"static%d%primary>nul
netshinterfaceipadddns"本地连接"%e%>nul
netshinterfaceipsetwins"本地连接"static%f%>nul
echo静态地址设置成功!!!
ping-n5127.0.0.1>nul
goto:eof

:x2
echo选择的是:%n%.自动获取
echo*******************************************************
echo*IP即将初始化为自动获取状态……*
netshinterfaceipsetaddress"本地连接"dhcp>nul
netshinterfaceipsetdns"本地连接"dhcp>nul
echo*******************************************************
echoDHCP设置成功!!!
ping-n5127.0.0.1>nul
goto:eof

pause


windows通过BAT脚本设置IP、DNS、

上一篇: CentOS8Stream报错处理 下一篇: 从IslandsArchitecture看前端有多卷