zoukankan      html  css  js  c++  java
  • Set IP address with DOS command

    Please try to save these text below as a *.bat file, then excute it, you will be able to set the IP address on your local PC in a simply way:

    ==================== IP Address Configruation Batch Process Source ==========================

    @echo off
    title IP自动设置
    MODE con: COLS=80 lines=30
    color 0a

    :main
    cls

    echo IP Manager Tool
    echo.
    echo 要把IP设置为公司用的IP 请按 1
    echo 要把IP设置为自动获取 请按 2
    echo 要退出 请按 3
    echo.

    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, 子网掩码, 网关地址
    netsh interface ip set address "本地连接" static 10.10.120.121 255.0.0.0 10.10.120.8
    @rem 以上这句是设置IP为10.10.120.121 子网掩码为255.0.0.0 网关为10.10.120.8

    echo      正在设置DNS服务器
    netsh -c interface ip set dns name="本地连接" source=static addr=10.10.120.8 register=PRIMARY
    @rem 以上这句为设置DNS为10.10.120.8

    echo      正在设置备用DNS服务器
    netsh -c interface ip add dns name="本地连接" addr=10.10.120.11
    @rem 以上这句为设置备用DNS为10.10.120.8

    echo      设置完成
    echo.
     
    CHOICE /C YN /M "退出请按 Y,返回菜单请按 N。"

    if errorlevel 2 goto main
    if errorlevel 1 goto end


    :ip2
    echo  IP自动设置开始....
    echo.
    echo  自动获取IP地址....
    netsh interface ip set address name = "本地连接" source = dhcp
    echo  自动获取DNS服务器....
    netsh interface ip set dns name = "本地连接" source = dhcp

    @rem 设置自动获取IP
    echo      设置完成
    echo. 
    CHOICE /C YN /M "退出请按 Y,返回菜单请按 N。"

    if errorlevel 2 goto main
    if errorlevel 1 goto end

    :test
    netsh interface ip set address name = "本地连接" source = dhcp

    netsh interface ip set dns name = "本地连接" source = dhcp

    netsh interface ip set wins name = "本地连接" source = dhcp

    CHOICE /C YN /M "退出请按 Y,返回菜单请按 N。"

    if errorlevel 2 goto main
    if errorlevel 1 goto end

    :end

  • 相关阅读:
    编程实现折半法查找
    浅谈C++多态性
    纯虚函数的使用汇总
    虚函数如何实现多态 ?
    重载(overload),覆盖(override),隐藏(hide)的区别
    Qt入门之常用Qt标准对话框之QMessageBox
    Qt5学习笔记(5)——列表框QListWidget类
    python 文件的方法
    python---while循环
    python ---strip()方法,split()方法,删除字符串开头或结尾,字符串分隔
  • 原文地址:https://www.cnblogs.com/chenjunsheep/p/2150556.html
Copyright © 2011-2022 走看看