自己写了个IP小工具 代码有些累赘 相同代码太多 请大佬帮忙优化精简- @echo off
- title I P修改小工具 Ver 1.0 【 污、克里里 】
- mode con: cols=64 lines=45 & color 0b
- :loop
- CLS
- @echo.
- @echo ※※※※※※※※※※※※※※※※※※※※※※※※※※※※
- @echo ※ ※
- @echo ※ I P 修 改 小 工 具 v 1.0 ※
- @echo ※ ※
- @echo ※ ※
- @echo ※ 「A」- 自 动 获 取 IP ※
- @echo ※ ※
- @echo ※ 「0」 —→ 192 . 168 . 0 . 1 ※
- @echo ※ ※
- @echo ※ 「1」 —→ 192 . 168 . 1 . 1 ※
- @echo ※ ※
- @echo ※ 「2」 —→ 192 . 168 . 2 . 1 ※
- @echo ※ ※
- @echo ※ 「3」 —→ 192 . 168 . 3 . 1 ※
- @echo ※ ※
- @echo ※ 「4」 —→ 192 . 168 . 5 . 1 ※
- @echo ※ ※
- @echo ※ 「5」 —→ 192 . 168 . 6 . 1 ※
- @echo ※ ※
- @echo ※ 「6」 —→ 192 . 168 . 9 . 1 ※
- @echo ※ ※
- @echo ※ 「7」 —→ 192 . 168 . 10 . 1 ※
- @echo ※ ※
- @echo ※ 「8」 —→ 192 . 168 . 99 . 1 ※
- @echo ※ ※
- @echo ※ 「9」 —→ 192 . 168 . 100 . 1 ※
- @echo ※ ※
- @echo ※ 「S」- 手 动 输 入 ※
- @echo ※ ※
- @echo ※ 「D」- D N S 修 改 ※
- @echo ※ ※
- @echo ※ 「I」- I P 修 改 ※
- @echo ※ ※
- @echo ※ 「W」- 网 关 修 改 ※
- @echo ※ ※
- @echo ※ 「R」- 重 启 网 卡 ※
- @echo ※ ※
- @echo ※ 「Z」- 退 出 程 序 ※
- @echo ※ ※
- @echo ※※※※※※※※※※※※※※※※※※※※※※※※※※※※
- @echo.
- @echo.
-
- @ SET /P ST="请输入序号:"
- echo.
- if /I "%ST%"=="A" goto setupA
- if /I "%ST%"=="0" goto setup0
- if /I "%ST%"=="1" goto setup1
- if /I "%ST%"=="2" goto setup2
- if /I "%ST%"=="3" goto setup3
- if /I "%ST%"=="4" goto setup4
- if /I "%ST%"=="5" goto setup5
- if /I "%ST%"=="6" goto setup6
- if /I "%ST%"=="7" goto setup7
- if /I "%ST%"=="8" goto setup8
- if /I "%ST%"=="9" goto setup9
- if /I "%ST%"=="S" goto setupS
- if /I "%ST%"=="D" goto setupD
- if /I "%ST%"=="I" goto setupI
- if /I "%ST%"=="W" goto setupW
- if /i "%ST%"=="R" goto rebootnet
- if /i "%ST%"=="Z" goto END
- goto loop
-
- REM 新IP地址/前缀=Newip
- REM 设置子网掩码=Netmask
- REM 设置网关=Gateway
- REM 设置DNS Sever1=Dns1
- REM 设置DNS Sever2=Dns2
-
- :setupA
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- wmic nicconfig where index="%index%" call enabledhcp
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder()
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 自动获取IP地址成功!
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
- :setup0
- set "Newip=192.168.0.2"
- set "Netmask=255.255.255.0"
- set "Gateway=192.168.0.1"
- set "Dns1=223.5.5.5"
- set "Dns2=223.6.6.6"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 成功设置本地连接IP地址和DNS
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo 当前默认网关:%Gateway%
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setup1
- set "Newip=192.168.1.2"
- set "Netmask=255.255.255.0"
- set "Gateway=192.168.1.1"
- set "Dns1=223.5.5.5"
- set "Dns2=223.6.6.6"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 成功设置本地连接IP地址和DNS
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo 当前默认网关:%Gateway%
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setup2
- set "Newip=192.168.2.2"
- set "Netmask=255.255.255.0"
- set "Gateway=192.168.2.1"
- set "Dns1=223.5.5.5"
- set "Dns2=223.6.6.6"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 成功设置本地连接IP地址和DNS
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo 当前默认网关:%Gateway%
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setup3
- set "Newip=192.168.3.2"
- set "Netmask=255.255.255.0"
- set "Gateway=192.168.3.1"
- set "Dns1=223.5.5.5"
- set "Dns2=223.6.6.6"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 成功设置本地连接IP地址和DNS
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo 当前默认网关:%Gateway%
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setup4
- set "Newip=192.168.5.2"
- set "Netmask=255.255.255.0"
- set "Gateway=192.168.5.1"
- set "Dns1=223.5.5.5"
- set "Dns2=223.6.6.6"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 成功设置本地连接IP地址和DNS
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo 当前默认网关:%Gateway%
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setup5
- set "Newip=192.168.6.2"
- set "Netmask=255.255.255.0"
- set "Gateway=192.168.6.1"
- set "Dns1=223.5.5.5"
- set "Dns2=223.6.6.6"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 成功设置本地连接IP地址和DNS
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo 当前默认网关:%Gateway%
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setup6
- set "Newip=192.168.9.2"
- set "Netmask=255.255.255.0"
- set "Gateway=192.168.9.1"
- set "Dns1=223.5.5.5"
- set "Dns2=223.6.6.6"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 成功设置本地连接IP地址和DNS
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo 当前默认网关:%Gateway%
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setup7
- set "Newip=192.168.10.2"
- set "Netmask=255.255.255.0"
- set "Gateway=192.168.10.1"
- set "Dns1=223.5.5.5"
- set "Dns2=223.6.6.6"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 成功设置本地连接IP地址和DNS
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo 当前默认网关:%Gateway%
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setup8
- set "Newip=192.168.99.2"
- set "Netmask=255.255.255.0"
- set "Gateway=192.168.99.1"
- set "Dns1=223.5.5.5"
- set "Dns2=223.6.6.6"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 成功设置本地连接IP地址和DNS
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo 当前默认网关:%Gateway%
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setup9
- set "Newip=192.168.100.2"
- set "Netmask=255.255.255.0"
- set "Gateway=192.168.100.1"
- set "Dns1=223.5.5.5"
- set "Dns2=223.6.6.6"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 成功设置本地连接IP地址和DNS
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo 当前默认网关:%Gateway%
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setupS
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- cls
- @echo.
- @echo ******手动设置本地连接IP地址,输入完成请回车确定******
- @echo.
- @echo.
- set /p Newip="请输入 IP 地址:"
- @echo.
- set "Netmask=255.255.255.0"
- @echo.
- set /p Gateway="请输入默认网关:"
- @echo.
- set "Dns1=223.5.5.5"
- set "Dns2=223.6.6.6"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 成功设置本地连接IP地址和DNS
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo 当前默认网关:%Gateway%
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setupD
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- cls
- @echo.
- @echo ******手动设置DNS地址,输入完成请回车确定******
- @echo.
- @echo.
- set /p Dns1="请输入 首选DNS 地址:"
- @echo.
- set /p Dns2="请输入 备用DNS 地址:"
-
- wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%Dns1%","%Dns2%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo D N S 修 改 完 成 !
- @echo.
- @echo 当前首选 DNS:%Dns1%
- @echo 当前备用 DNS:%Dns2%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setupI
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- cls
- @echo.
- @echo ******手动设置IP地址,输入完成请回车确定******
- @echo.
- @echo.
- set /p Newip="请输入 IP 地址:"
- @echo.
- set "Netmask=255.255.255.0"
-
- wmic nicconfig where index="%index%" call enablestatic("%Newip%"),("%Netmask%")
- wmic nicconfig where index="%index%" call SetTcpipNetbios 2
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo I P 修 改 完 成 !
- @echo.
- @echo 当前 IP 地址:%Newip%
- @echo 当前子网掩码:%Netmask%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :setupW
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- cls
- @echo.
- @echo ******手动设置网关地址,输入完成请回车确定******
- @echo.
- @echo.
- set /p Gateway="请输入默认网关:"
-
- wmic nicconfig where index="%index%" call setgateways("%Gateway%"),(1)
-
- netsh interface set interface "%NetConnectionID%" disabled
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 网 关 修 改 完 成 !
- @echo.
- @echo 当前网关地址:%Gateway%
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
- :rebootnet
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%A
- echo NetConnectionID="%NetConnectionID%"
-
- for /f "tokens=*" %%A in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index /value^|find "="') do set %%A
- echo index="%index%"
-
- ping -n 3 127.1>nul
-
- netsh interface set interface "%NetConnectionID%" disabled
-
- netsh interface set interface "%NetConnectionID%" enable
-
- cls
- set a=^set /p=■%b%^<nul^&ping/n 0 127.1^>nul^&
- echo.
- set/p= <nul&%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%%a%
- echo 100%%
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo -------------------------------------
- @echo 网卡重启成功!
- @echo -------------------------------------
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @echo.
- @ pause
- goto loop
-
-
-
- :end
-
- Endlocal
-
- ping -n 3 127.1>nul
-
- exit
复制代码
|