一键ip设置dns设置批处理.docxVIP

  • 32
  • 0
  • 约1.44千字
  • 约 2页
  • 2021-11-14 发布于江苏
  • 举报
@echo off title --自IP动设置 -- MODE con: COLS=80 lines=30 color 0a :main cls echo 按提示操作echo. echo 设置为公司用IP 请按 1 echo 设置为自动获取 请按 2 echo 要退出 请按 3 echo. @rem 上一句是空一行 set /p choice= 您的选择: echo. if %choice%==1 goto ip1 if %choice%==2 goto ip2 if %choice%==3 goto end if %choice%==4 goto test goto main :ip1 echo IP自动设置开始.... echo. echo 正在设置IP 及子网掩码 cmd /c netsh interfaceip set addressname= 本地连接 source=statiacddr=【IP 地址】 mask=255.255.255.0 gatewa【y=网关】 gwmetric=1 echo 正在设置DNS 服务器 cmd /c netsh interfaceip set dns name= 本地连接 source=statiacddr=【DNS 地址】 register=PRIMARY @rem 以上这句为设置DNS 为 202.101.224.68 echo 正在设置DNS 服务器 cmd /c netsh interface ip add dns本n地am连e=接  addr【= DNS 地址】 @rem 以上这句为设置DNS 为 202.101.224.68 echo 设置完成 pause exit if errorlevel 2 goto main if errorlevel 1 goto end :ip2 echo IP自动设置开始.... echo. echo 自动获取IP 地址.... netsh interface ip set address 本na地me连=接 echo 自动获取DNS 服务器....  source = dhcp netsh interface ip set dns n本am地e 连= 接 source = dhcp @rem 设置自动获取IP echo 设置完成 pause exit if errorlevel 2 goto main if errorlevel 1 goto end :test netsh inte***ce ip set address n本am地e 连= 接 source = dhcp netsh inte***ce ip set dns na本me地=连接 source = dhcp netsh inte***ce ip set wins na本me地=连接 source = dhcp CHOICE /C YN /M 退出请按 Y ,返回菜单请按 N 。 if errorlevel 2 goto main if errorlevel 1 goto end :end ————————————————————分割线———————————————— ——— 将以上保存为.bat结尾的文件即可。 使用方法:运行改文件后有两个选项,2 为设置自动获取,1 为设置固定 IP, 若要使用选项 1,请将上述代码中的【IP 地址】【网关】【DNS 地址】 替换为本机地址即可。

文档评论(0)

1亿VIP精品文档

相关文档