记:由于每次本机与设备调试+本机切内网需要来回设置IP,导致很麻烦,所以便写了这个脚本,很简单,遂记录一下。
First:对bat脚本语言不熟悉的,或者想了解一下各个命令的作用,请移步bat(批处理文件类型)常用命令
一、bat修改网卡IP信息
主要功能:文章来源:https://www.toymoban.com/news/detail-739261.html
- 手动设置IP
- 设置为自动获取
- 设置为默认IP
@echo off
chcp 65001
color 0B
mode con cols=100 lines=30
title IP切换 by:zhenglg
rem IP切换 by:zhenglg
rem date: 2023-02-08
rem version:V1.0.0
echo Configure IP Adress
echo 1: By Auto
echo 2: By Manual
set /p sel=Please Make Your Choice :
if "%sel%"=="1" goto Auto
if "%sel%"=="2" goto Manual
echo Input Error, Please Select Again
goto End
:Auto
::netsh interface ip set address name ="Net_First" source = dhcp
::netsh interface ip set dns name ="Net_First" source = dhcp
netsh interface ip set address name ="Net_First" source = dhcp
netsh interface ip delete dns "Net_First" all
ipconfig /flushdns
echo Change IP Adress By Auto Success!
goto End
:Manual
echo Configure IP Adress By Manual:
echo 1: Use Default
echo 2: Configure
set /p Input=Please Make Your Choice :
if /i "%Input%"=="1" (
goto Default
) ^
else if /i "%Input%"=="2" (
goto Configure
) ^
else (
goto End
)
:Configure
set /p ip_manual=Please Input Your IP Adress:
set /p netmask_manual=Please Input Your NetMask:
set /p gatewat_manual=Please Input Your GateWay:
netsh interface ip set address name="Net_First" source=static addr=%ip_manual% mask=%netmask_manual% gateway=%gatewat_manual% gwmetric=1
netsh interface ip set dns name ="Net_First" source=dhcp
ipconfig /flushdns
echo Change IP Adress By Manual Success!
goto End
:Default
netsh interface ip set address name="Net_First" source=static addr=192.168.200.211 mask=255.255.255.0 gateway=192.168.200.1 gwmetric=1
netsh interface ip set dns name ="Net_First" source=dhcp
ipconfig /flushdns
echo Change IP Adress By Manual Success!
goto End
:End
exit
二、注意事项
- 此处,本人将网卡名设置为“Net_First”,最好是将你的网卡也修改为英文。
- 修改网卡名:打开“网络和Internet 设置” -> “更改适配器选项” -> “选中需要修改的网卡” -> “右键重命名即可”。
2023-03-26
ChengDu China
ZLG文章来源地址https://www.toymoban.com/news/detail-739261.html
到了这里,关于bat脚本修改网卡IP信息的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!