Created
June 3, 2022 08:11
-
-
Save hui-shao/5e8c044cc37d7536d6199fe2ed831804 to your computer and use it in GitHub Desktop.
IPv6 / IPv4 优先级选择
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
title IPv4 / IPv6 优先级选择工具 | |
mode con lines=12 cols=48 | |
color 8f | |
REM ________________________________________________________________ | |
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
if '%errorlevel%' NEQ '0' ( | |
echo 请求管理员权限... | |
goto UACPrompt | |
) else ( goto gotAdmin ) | |
:UACPrompt | |
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" | |
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" | |
"%temp%\getadmin.vbs" | |
exit /B | |
:gotAdmin | |
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) | |
pushd "%CD%" | |
CD /D "%~dp0" | |
goto A | |
REM ________________________________________________________________ | |
:A | |
Rem 删除临时文件 | |
del %TempFile_Name% 1>nul 2>nul | |
CLS | |
color 3f | |
mode con lines=35 cols=100 | |
cd /d %~dp0 | |
:menu | |
cls | |
ECHO. ============================================================== | |
ECHO. IPv4 / IPv6 优先级选择工具 by Hui-Shao | |
ECHO. | |
echo 注意 此注册表值不影响网络属性GUI复选框的状态 | |
echo. | |
echo 部分系统可能需要重启后生效 | |
echo. | |
echo. | |
echo ----------------------请选择(序号)---------------------------- | |
echo. | |
echo 1. 首选IPv4 - 设为 0x20 | |
echo 2. 默认值(首选IPv6) - 设为 0x00 | |
echo 3. 默认值(首选IPv6) - 并删除 DisabledComponents | |
echo 4. 退出 | |
echo. | |
ECHO. ============================================================== | |
ECHO. | |
set input= | |
set /p input= 选择: | |
echo. | |
IF /I "%input%"=="1" GOTO ipv4 | |
IF /I "%input%"=="2" GOTO ipv6 | |
IF /I "%input%"=="3" GOTO delete | |
IF /I "%input%"=="4" exit | |
cls | |
color cf | |
echo. | |
echo. | |
echo 选择无效,请重新输入 | |
echo. | |
ping 127.0.0.1 /n 3 >nul | |
goto menu | |
:ipv4 | |
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters" /v DisabledComponents /t REG_DWORD /d 32 /f | |
ping 127.0.0.1 /n 2 >nul | |
goto menu | |
:ipv6 | |
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters" /v DisabledComponents /t REG_DWORD /d 0 /f | |
ping 127.0.0.1 /n 2 >nul | |
goto menu | |
:delete | |
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters" /v DisabledComponents /f | |
ping 127.0.0.1 /n 2 >nul | |
goto menu | |
REM https://docs.microsoft.com/zh-cn/troubleshoot/windows-server/networking/configure-ipv6-in-windows |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment