本帖最后由 wujunkai 于 2020-4-6 18:27 编辑
回复 1# wwdzcdb
还可以继续化简,等我有空。。。。- @echo off & setlocal enabledelayedexpansion
- title I P修改小工具 Ver 1.0 【 污、克里里 】
- mode con: cols=64 lines=45 & color 0b
-
- for %%i in ("IP[0]=0","IP[1]=1","IP[2]=2","IP[3]=3","IP[4]=5","IP[5]=6","IP[6]=9","IP[7]=10","IP[8]=99","IP[9]=100") do set %%i
-
- :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="请输入序号:"
- if /I "%ST%"=="A" call:setupA
- if /I "%ST%"=="0" call:setup 0
- if /I "%ST%"=="1" call:setup 1
- if /I "%ST%"=="2" call:setup 2
- if /I "%ST%"=="3" call:setup 3
- if /I "%ST%"=="4" call:setup 4
- if /I "%ST%"=="5" call:setup 5
- if /I "%ST%"=="6" call:setup 6
- if /I "%ST%"=="7" call:setup 7
- if /I "%ST%"=="8" call:setup 8
- if /I "%ST%"=="9" call:setup 9
- if /I "%ST%"=="S" call:setupS
- if /I "%ST%"=="D" call:setupD
- if /I "%ST%"=="I" call:setupI
- if /I "%ST%"=="W" call: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
-
- :show
- 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%%
- call:endl 5
- echo -------------------------------------
- echo 成功设置本地连接IP地址和DNS
- echo=
- echo 当前 IP 地址:%Newip%
- echo 当前子网掩码:%Netmask%
- echo 当前默认网关:%Gateway%
- echo 当前首选 DNS:%Dns1%
- echo 当前备用 DNS:%Dns2%
- echo -------------------------------------
- call:endl 8
- goto:eof
-
- :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%%
- call:endl 5
- echo -------------------------------------
- echo 自动获取IP地址成功!
- echo -------------------------------------
- call:endl 8
- pause
- goto:loop
-
-
- :setup
- set "Newip=192.168.!IP[%~1]!.2"
- set "Gateway=192.168.!IP[%~1]!.1"
- set "Netmask=255.255.255.0"
- 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
- call:show
- 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
- call:show
- 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%%
- call:endl 5
- echo -------------------------------------
- echo D N S 修 改 完 成 !
- echo=
- echo 当前首选 DNS:%Dns1%
- echo 当前备用 DNS:%Dns2%
- echo -------------------------------------
- call:endl 8
- 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%%
- call:endl 5
- echo -------------------------------------
- echo I P 修 改 完 成 !
- echo=
- echo 当前 IP 地址:%Newip%
- echo 当前子网掩码:%Netmask%
- echo -------------------------------------
- call:endl 8
- 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%%
- call:endl 5
- echo -------------------------------------
- echo 网 关 修 改 完 成 !
- echo=
- echo 当前网关地址:%Gateway%
- echo -------------------------------------
- call:endl 8
- 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%%
- call:endl 5
- echo -------------------------------------
- echo 网卡重启成功!
- echo -------------------------------------
- call:endl 8
- pause
- goto:loop
-
-
- :endl
- for /L %%a in (1,1,%~1) do echo=
- goto:eof
-
-
- :end
- endlocal
- ping -n 3 127.1>nul
- exit
- goto:eof
复制代码
|