另存为cmd本地管理员模式运行;修改参数可以分别测试windows或者是office的开关。

<!-- : 批处理脚本开始@setlocal DisableDelayedExpansion@set uivr=v44@echo off:: ### 配置选项 ###:: 将此参数更改为 1 以启用调试模式(可以与无人参与的选项一起使用)set _Debug=0:: 更改参数为 0 以通过脚本关闭 Windows 或 Office 激活set ActWindows=1set ActOffice=0:: 将此参数更改为 0 可关闭 Office C2R 零售到批量的自动转换set AutoR2V=1:: 将此参数更改为 0 以将 Windows 10/11 KMS38 还原为正常 KMSset SkipKMS38=1:: ### 无人值守选项 ###:: 将此参数更改为 1 并设置 KMS_IP 地址以通过无人值守的外部 KMS 服务器激活set External=0set KMS_IP=0.0.0.0:: 将此参数更改为 1 以运行无人参与的手动激活模式set uManual=0:: 将此参数更改为 1 可在无人值守的情况下运行自动更新激活模式set uAutoRenewal=1:: 将此参数更改为 1 以抑制任何输出set Silent=0:: 将此参数更改为 1 可将输出重定向到文本文件,仅工作在参数 Silent=1set Logger=0:: ### 高级选项 ###:: 更改 KMS 自动续订时间表,范围以分钟为单位:从 1543200:: 示例:10080 = 每周,1440 = 每日,43200 = 每月set KMS_RenewalInterval=10080:: 更改 KMS 重新尝试失败激活或未激活的时间表,范围以分钟为单位:从 1543200set KMS_ActivationInterval=120:: 更改本地 KMS 仿真器服务器的硬件哈希值(仅影响 Windows 8.110set KMS_HWID=0x3A1C049600B60076:: 更改 KMS TCP 端口set KMS_Port=1688:: Windows 64 位(x64 / ARM64)高级用户须知::: 当你将 KMS_VL_ALL 脚本捆绑在自解压程序中或从另一个命令脚本中运行时,:: 如果 exe 包或调用脚本作为 32 位(x86)进程运行,:: KMS_VL_ALL 脚本将会关闭,然后使用 64 位(x64 / ARM64)cmd.exe 重新启动:: 在这种情况下,建议不要根据 KMS_VL_ALL 脚本的关闭来继续执行你的包或调用脚本,:: 请确保 exe 包或其他调用脚本已经是 64 位(x64 / ARM64)进程:: ###################################################################:: #                正常情况不需要更改下以下任何内容                 #:: ###################################################################set KMS_Emulation=1set Unattend=0set _uIP=0.0.0.0set "_Null=1>nul 2>nul"set "_cmdf=%~f0"if exist "%SystemRoot%\Sysnative\cmd.exe" (setlocal EnableDelayedExpansionstart %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %*"exit /b)if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 (setlocal EnableDelayedExpansionstart %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %*"exit /b)set _args=set _elev=set _batf=set _batp=set fAUR=set rAUR=set _args=%*if not defined _args goto :NoProgArgsset _args=%_args:"=%for %%A in (%_args%) do (if /i "%%A"=="-elevated" (set _elev=1) else if /i "%%A"=="/d" (set _Debug=1) else if /i "%%A"=="/u" (set Unattend=1) else if /i "%%A"=="/s" (set Silent=1) else if /i "%%A"=="/l" (set Logger=1) else if /i "%%A"=="/o" (set ActOffice=1&set ActWindows=0) else if /i "%%A"=="/w" (set ActOffice=0&set ActWindows=1) else if /i "%%A"=="/c" (set AutoR2V=0) else if /i "%%A"=="/x" (set SkipKMS38=0) else if /i "%%A"=="/e" (set fAUR=0&set External=1&set uManual=0&set uAutoRenewal=0) else if /i "%%A"=="/m" (set fAUR=0&set External=0&set uAutoRenewal=0) else if /i "%%A"=="/a" (set fAUR=1&set External=0&set uManual=0) else if /i "%%A"=="/r" (set rAUR=1) else (set "KMS_IP=%%A")):NoProgArgsif %External% EQU 1 (if "%KMS_IP%"=="%_uIP%" (set fAUR=0&set External=0) else (set fAUR=0))if %uManual% EQU 1 (set fAUR=0&set External=0&set uAutoRenewal=0)if %uAutoRenewal% EQU 1 (set fAUR=1&set External=0&set uManual=0)if defined fAUR set Unattend=1if defined rAUR set Unattend=1if %Silent% EQU 1 set Unattend=1set _run=nulif %Logger% EQU 1 set _run="%~dpn0_Silent.log"set "SysPath=%SystemRoot%\System32"if exist "%SystemRoot%\Sysnative\reg.exe" (set "SysPath=%SystemRoot%\Sysnative")set "Path=%SysPath%;%SystemRoot%;%SysPath%\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\"set "_err===== 出现错误 ===="set "_psc=powershell -nop -c"set "_buf={$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=300;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}"set "o_x64=684103f5c312ae956e66a02b965d9aad59710745"set "o_x86=da8f931c7f3bc6643e20063e075cd8fa044b53ae"set "o_arm=1139ae6243934ca621e6d4ed2e2f34cc130ef88a"set "_bit=64"set "_wow=1"if /i "%PROCESSOR_ARCHITECTURE%"=="amd64" set "xBit=x64"&set "xOS=x64"&set "_orig=%o_x64%"if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" set "xBit=x86"&set "xOS=A64"&set "_orig=%o_arm%"if /i "%PROCESSOR_ARCHITECTURE%"=="x86" if "%PROCESSOR_ARCHITEW6432%"=="" set "xBit=x86"&set "xOS=x86"&set "_orig=%o_x86%"&set "_wow=0"&set "_bit=32"if /i "%PROCESSOR_ARCHITEW6432%"=="amd64" set "xBit=x64"&set "xOS=x64"&set "_orig=%o_x64%"if /i "%PROCESSOR_ARCHITEW6432%"=="arm64" set "xBit=x86"&set "xOS=A64"&set "_orig=%o_arm%"if not exist "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" goto :E_PSset pwsh32=0if %xOS%==A64 %_psc% $env:PROCESSOR_ARCHITECTURE 2>nul | find /i "x86" 1>nul && set pwsh32=1set _dllPath=%SystemRoot%\System32if %pwsh32% EQU 1 set _dllPath=%SystemRoot%\Sysnativeset _dllNum=1if %xOS%==x64 set _dllNum=2if %xOS%==A64 set _dllNum=3set preparedcolor=01>nul 2>nul reg query HKU\S-1-5-19 && (goto :Passed) || (if defined _elev goto :E_Admin)set _PSarg="""%~f0""" %_args% -elevatedset _PSarg=%_PSarg:'=''%(1>nul 2>nul cscript //NoLogo "%~f0?.wsf" //job:ELAV /File:"%~f0" %_args% -elevated) && (exit /b) || (call setlocal EnableDelayedExpansion1>nul 2>nul %SysPath%\WindowsPowerShell\v1.0\%_psc% "start cmd.exe -arg '/c \"!_PSarg!\"' -verb runas" && (exit /b) || (goto :E_Admin)):Passedset "_batf=%~f0"set "_batp=%_batf:'=''%"set "_Local=%LocalAppData%"set "_utemp=%TEMP%"set "_temp=%SystemRoot%\Temp"set "_log=%~dpn0"set "_work=%~dp0"if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%"set _UNC=0if "%_work:~0,2%"=="\\" set _UNC=1for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') do call set "_dsk=%%b"if exist "%PUBLIC%\Desktop\desktop.ini" set "_dsk=%PUBLIC%\Desktop"set "_mO21a=检测到 Office 2021 C2R 零售版本已经激活"set "_mO19a=检测到 Office 2019 C2R 零售版本已经激活"set "_mO16a=检测到 Office 2016 C2R 零售版本已经激活"set "_mO15a=检测到 Office 2013 C2R 零售版本已经激活"set "_mO21c=检测到 Office 2021 C2R 零售版本无法转换为批量版本"set "_mO19c=检测到 Office 2019 C2R 零售版本无法转换为批量版本"set "_mO16c=检测到 Office 2016 C2R 零售版本无法转换为批量版本"set "_mO15c=检测到 Office 2013 C2R 零售版本无法转换为批量版本"set "_mO14c=检测到 Office 2010 C2R 零售版本不支持 KMS_VL_ALL"set "_mO14m=检测到 Office 2010 MSI 零售版本不支持 KMS_VL_ALL"set "_mO15m=检测到 Office 2013 MSI 零售版本不支持 KMS_VL_ALL"set "_mO16m=检测到 Office 2016 MSI 零售版本不支持 KMS_VL_ALL"set "_mOuwp=检测到 Office 365/2016 UWP 不支持 KMS_VL_ALL"set DO16Ids=ProPlus,ProjectPro,VisioPro,Standard,ProjectStd,VisioStd,Access,SkypeforBusiness,Excel,Outlook,PowerPoint,Publisher,Wordset LV16Ids=Mondo,ProPlus,ProjectPro,VisioPro,Standard,ProjectStd,VisioStd,Access,SkypeforBusiness,OneNote,Excel,Outlook,PowerPoint,Publisher,Wordset LR16Ids=%LV16Ids%,Professional,HomeBusiness,HomeStudent,O365Business,O365SmallBusPrem,O365HomePrem,O365EduCloudset "ESUEditions=Enterprise,EnterpriseE,EnterpriseN,Professional,ProfessionalE,ProfessionalN,Ultimate,UltimateE,UltimateN"if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (set "ESUEditions=ServerDatacenter,ServerDatacenterCore,ServerDatacenterV,ServerDatacenterVCore,ServerStandard,ServerStandardCore,ServerStandardV,ServerStandardVCore,ServerEnterprise,ServerEnterpriseCore,ServerEnterpriseV,ServerEnterpriseVCore")setlocal EnableDelayedExpansionif %_Debug% EQU 0 (set "_Nul1=1>nul"set "_Nul2=2>nul"set "_Nul6=2^>nul"set "_Nul3=1>nul 2>nul"set "_Pause=pause >nul"if %Unattend% EQU 1 set "_Pause="if %Silent% EQU 0 (call :Begin) else (call :Begin >!_run! 2>&1)) else (set "_Nul1="set "_Nul2="set "_Nul6="set "_Nul3="set "_Pause="copy /y nul "!_work!\#.rw" 1>nul 2>nul && (if exist "!_work!\#.rw" del /f /q "!_work!\#.rw") || (set "_log=!_dsk!\%~n0")if exist "!_log!_Debug.log" (call set "_suf="for /f "tokens=2 delims==." %%# in ('wmic os get localdatetime /value') do set "_date=%%#"set "_suf=_!_date:~8,6!")if %Silent% EQU 0 (echo.echo 正在调试模式下运行……if not defined _args (echo 当完成之后,此窗口将会关闭) else (echo 请稍侯……)echo.echo 正在写入调试日志到:echo "!_log!_Debug!_suf!.log")@echo on@prompt $G@call :Begin >"!_log!_tmp.log" 2>&1 &cmd /u /c type "!_log!_tmp.log">"!_log!_Debug!_suf!.log"&del "!_log!_tmp.log")@color 07@title %ComSpec%@echo off@exit /b:Beginif %_Debug% EQU 1 (if defined _args echo %_args%echo "!_batf!")if exist "%PUBLIC%\ReadMeAIO.html" del /f /q "%PUBLIC%\ReadMeAIO.html"if exist "%_temp%\'" del /f /q "%_temp%\'"if exist "%_temp%\`.txt" del /f /q "%_temp%\`.txt"set _verb=0set "_wApp=55c92734-d682-4d71-983e-d6ec3f16059f"set "_oApp=0ff1ce15-a989-479d-af46-f275c6370663"set "_oA14=59a52881-a989-479d-af46-f275c6370663"set "IFEO=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"set "OPPk=SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform"set "SPPk=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"set _Hook="%SysPath%\SppExtComObjHook.dll"set w7inf=%SystemRoot%\Migration\WTR\KMS_VL_ALL.infset "_TaskEx=\Microsoft\Windows\SoftwareProtectionPlatform\SvcTrigger"set "_TaskOs=\Microsoft\Windows\SoftwareProtectionPlatform\SvcRestartTaskLogon"set "line1============================================================="set "line2=************************************************************"set "line3=____________________________________________________________"set "line4=__________________________________________________"for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%Gset SSppHook=0for /f %%A in ('dir /b /ad %SysPath%\spp\tokens\skus') do (if %winbuild% GEQ 9200 if exist "%SysPath%\spp\tokens\skus\%%A\*GVLK*.xrm-ms" set SSppHook=1if %winbuild% LSS 9200 if exist "%SysPath%\spp\tokens\skus\%%A\*VLKMS*.xrm-ms" set SSppHook=1if %winbuild% LSS 9200 if exist "%SysPath%\spp\tokens\skus\%%A\*VL-BYPASS*.xrm-ms" set SSppHook=1)set OsppHook=1sc query osppsvc %_Nul3%if %errorlevel% EQU 1060 set OsppHook=0set ESU_KMS=0if %winbuild% LSS 9200 for /f %%A in ('dir /b /ad %SysPath%\spp\tokens\channels') do (if exist "%SysPath%\spp\tokens\channels\%%A\*VL-BYPASS*.xrm-ms" set ESU_KMS=1)if %ESU_KMS% EQU 1 (set "adoff=and LicenseDependsOn is NULL"&set "addon=and LicenseDependsOn is not NULL") else (set "adoff="&set "addon=")set ESU_EDT=0if %ESU_KMS% EQU 1 for %%A in (%ESUEditions%) do (if exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%%A\*.xrm-ms" set ESU_EDT=1)if %ESU_EDT% EQU 1 set SSppHook=1set ESU_ADD=0if %winbuild% GEQ 9200 (set OSType=Win8set SppVer=SppExtComObj.exe) else if %winbuild% GEQ 7600 (set OSType=Win7set SppVer=sppsvc.exe) else (goto :UnsupportedVersion)if %OSType% EQU Win8 reg query "%IFEO%\sppsvc.exe" %_Nul3% && (reg delete "%IFEO%\sppsvc.exe" /f %_Nul3%call :StopService sppsvc)set _uRI=%KMS_RenewalInterval%set _uAI=%KMS_ActivationInterval%set _dDbg=否if %ActWindows% EQU 0 if %ActOffice% EQU 0 set ActWindows=1if %_Debug% EQU 1 if not defined fAUR set fAUR=0&set External=0if %Unattend% EQU 1 if not defined fAUR set fAUR=0&set External=0if not defined fAUR if not defined rAUR goto :MainMenuif defined rAUR (set _verb=1&cls&call :RemoveHook&goto :cCache)set Unattend=1set _ReAR=0set _AUR=0if exist %_Hook% dir /b /al %_Hook% %_Nul3% || (reg query "%IFEO%\%SppVer%" /v VerifierFlags %_Nul3% && set _AUR=1if %SSppHook% EQU 0 reg query "%IFEO%\osppsvc.exe" /v VerifierFlags %_Nul3% && set _AUR=1)if %fAUR% EQU 1 (set _ReAR=1&if %_AUR% EQU 0 (set _AUR=1&set _verb=1&set _rtr=DoActivate&cls&goto :InstallHook) else (set _verb=0&set _rtr=DoActivate&cls&goto :InstallHook))if %External% EQU 0 (set _AUR=0&cls&goto :DoActivate)cls&goto :DoActivate:MainMenuclsmode con cols=80 lines=32color 07set "_title=KMS_VL_ALL_AIO %uivr%"title %_title%set _dmode=手动set _ReAR=0set _AUR=0if exist %_Hook% dir /b /al %_Hook% %_Nul3% || (reg query "%IFEO%\%SppVer%" /v VerifierFlags %_Nul3% && (set _AUR=1&set "_dmode=自动续期")if %SSppHook% EQU 0 reg query "%IFEO%\osppsvc.exe" /v VerifierFlags %_Nul3% && (set _AUR=1&set "_dmode=自动续期"))if %_AUR% EQU 0 (set "_dHook=未安装") else (set "_dHook=已安装")if %ActWindows% EQU 0 (set _dAwin=否) else (set _dAwin=是)if %ActOffice% EQU 0 (set _dAoff=否) else (set _dAoff=是)if %AutoR2V% EQU 0 (set _dArtv=否) else (set _dArtv=是)if %SkipKMS38% EQU 0 (set _dWXKMS=否) else (set _dWXKMS=是)if %_Debug% EQU 0 (set _dDbg=否) else (set _dDbg=是)set _el=set _quit=if %preparedcolor%==0 call :colorprepif %winbuild% LSS 10586 (pushd %_temp%if not exist "'" (<nul >"'" set /p "=."))echo.echo           %line3%echo.if %_AUR% EQU 1 (rem echo                [1] 激活                  [%_dMode%模式]call :Cfgbg %_cWht% "               [1] 激活                  " %_cGrn% "[%_dMode%模式]") else (call :Cfgbg %_cWht% "               [1] 激活                  " %_cBlu% "[%_dMode%模式]")echo.if %_AUR% EQU 1 (call :Cfgbg %_cWht% "               [2] 安装激活自动续期程序  " %_cGrn% "[%_dHook%]") else (echo                [2] 安装激活自动续期程序)echo                [3] 完整卸载echo                %line4%echo.echo                    配 置 选 项:echo.if %_dDbg%==No (echo                [4] 启用调试模式          [%_dDbg%]) else (call :Cfgbg %_cWht% "               [4] 启用调试模式          " %_cRed% "[%_dDbg%]")if %_dAwin%==Yes (echo                [5] 处理 Windows          [%_dAwin%]) else (call :Cfgbg %_cWht% "               [5] 处理 Windows          " %_cYel% "[%_dAwin%]")if %_dAoff%==Yes (echo                [6] 处理 Office           [%_dAoff%]) else (call :Cfgbg %_cWht% "               [6] 处理 Office           " %_cYel% "[%_dAoff%]")if %_dArtv%==Yes (echo                [7] 转换 Office C2R-R2V   [%_dArtv%]) else (call :Cfgbg %_cWht% "               [7] 转换 Office C2R-R2V   " %_cYel% "[%_dArtv%]")if %winbuild% GEQ 10240 (if %_dWXKMS%==Yes (echo                [X] 跳过 Windows 10 KMS38 [%_dWXKMS%]) else (call :Cfgbg %_cWht% "               [X] 跳过 Windows 10 KMS38 " %_cYel% "[%_dWXKMS%]"))echo                %line4%echo.echo                    其 他 选 项:echo.echo                [8] 检查激活状态          [vbs]echo                [9] 检查激活状态          [wmic]echo                [S] 创建 $OEM$ 文件夹echo                [R] 自述文件echo                [E] 激活                  [外部模式]echo           %line3%echo.if %winbuild% LSS 10586 (popd)choice /c 1234567890ERSX /n /m ">           从菜单中选择一个选项,或者按数字键 0 退出脚本:"set _el=%errorlevel%if %_el%==14 if %winbuild% GEQ 10240 (if %SkipKMS38% EQU 0 (set SkipKMS38=1) else (set SkipKMS38=0))&goto :MainMenuif %_el%==13 (call :CreateOEM)&goto :MainMenuif %_el%==12 (call :CreateReadMe)&goto :MainMenuif %_el%==11 goto :E_IPif %_el%==10 (set _quit=1&goto :TheEnd)if %_el%==9 (call :casWm)&goto :MainMenuif %_el%==8 (call :casVm)&goto :MainMenuif %_el%==7 (if %AutoR2V% EQU 0 (set AutoR2V=1) else (set AutoR2V=0))&goto :MainMenuif %_el%==6 (if %ActOffice% EQU 0 (set ActOffice=1) else (set ActWindows=1&set ActOffice=0))&goto :MainMenuif %_el%==5 (if %ActWindows% EQU 0 (set ActWindows=1) else (set ActWindows=0&set ActOffice=1))&goto :MainMenuif %_el%==4 (if %_Debug% EQU 0 (set _Debug=1) else (set _Debug=0))&goto :MainMenuif %_el%==3 (if %_dDbg%==No (set _verb=1&cls&call :RemoveHook&goto :cCache) else (set _verb=1&cls&goto :RemoveHook))if %_el%==2 (set _ReAR=1&if %_AUR% EQU 0 (set _AUR=1&set _verb=1&set _rtr=DoActivate&cls&goto :InstallHook) else (set _verb=0&set _rtr=DoActivate&cls&goto :InstallHook))if %_el%==1 (cls&goto :DoActivate)goto :MainMenu:colorprepset preparedcolor=1if %winbuild% GEQ 10586 (for /f "tokens=1,2 delims=#" %%A in ('"prompt #$H#$E# & echo on & for %%B in (1) do rem"') do set _EC=%%Bset "_cBlu="44;97m""set "_cRed="40;91m""set "_cGrn="40;92m""set "_cYel="40;93m""set "_cWht="40;37m""exit /b)for /f %%A in ('"prompt $H&for %%B in (1) do rem"') do set "_BS=%%A %%A"set "_cBlu="1F""set "_cRed="0C""set "_cGrn="0A""set "_cYel="0E""set "_cWht="07""exit /b:Cfgbgif %winbuild% GEQ 10586 (echo %_EC%[%~1%~2%_EC%[%~3%~4%_EC%[0mexit /b)setlocalset "s=%~2"set "t=%~4"call :Pfgbg %1 s %3 texit /b:Pfgbgsetlocal EnableDelayedExpansionset "s=!%~2!"set "t=!%~4!"for /f delims^=^ eol^= %%i in ("!s!") do (if "!" equ "" setlocal DisableDelayedExpansion>`.txt (echo %%i\..\')findstr /a:%~1 /f:`.txt "."<nul set /p "=%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%")setlocal EnableDelayedExpansionfor /f delims^=^ eol^= %%i in ("!t!") do (if "!" equ "" setlocal DisableDelayedExpansion>`.txt (echo %%i\..\')findstr /a:%~3 /f:`.txt "."<nul set /p "=%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%")echo(exit /b:E_IPclsset kip=echo.echo 请输入/粘贴外部 KMS 服务器地址,或仅按 Enter 键返回:echo.set /p kip=if not defined kip goto :MainMenuset "kip=%kip: =%"set "KMS_IP=%kip%"set External=1cls:DoActivateif %_dDbg%==Yes (set "_para=/d"if %ActWindows% EQU 0 set "_para=!_para! /o"if %ActOffice% EQU 0 set "_para=!_para! /w"if %SkipKMS38% EQU 0 set "_para=!_para! /x"if %External% EQU 1 set "_para=!_para! /e %KMS_IP%"if %External% EQU 0 if %_AUR% EQU 0 set "_para=!_para! /m"if %External% EQU 0 if %_AUR% EQU 1 set "_para=!_para! /a"goto :DoDebug)if %External% EQU 1 (if "%KMS_IP%"=="%_uIP%" set External=0)if %External% EQU 1 (set _AUR=1)if %External% EQU 0 (set KMS_IP=%_uIP%)if %_AUR% EQU 0 (set KMS_RenewalInterval=43200set KMS_ActivationInterval=43200) else (set KMS_RenewalInterval=%_uRI%set KMS_ActivationInterval=%_uAI%)if %External% EQU 1 (color 8F&set "mode=外部(%KMS_IP%)") else (if %_AUR% EQU 0 (color 1F&set "mode=手动") else (color 07&set "mode=自动续期"))if %Unattend% EQU 0 (if %_Debug% EQU 0 (title %_title%) else (set "_title=KMS_VL_ALL_AIO %uivr%%mode%"&title KMS_VL_ALL_AIO %uivr%%mode%)) else (echo.echo 正在运行 KMS_VL_ALL_AIO %uivr%)if %Silent% EQU 0 if %_Debug% EQU 0 (%_Nul3% %_psc% "&%_buf%"if %Unattend% EQU 0 title %_title%)if %winbuild% GEQ 9600 (reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform" /v NoGenTicket /t REG_DWORD /d 1 /f %_Nul3%if %winbuild% EQU 14393 reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform" /v NoAcquireGT /t REG_DWORD /d 1 /f %_Nul3%)echo.echo 激活模式:%mode%call :StopService sppsvcif %OsppHook% NEQ 0 call :StopService osppsvcif %External% EQU 0 if %_ReAR% EQU 0 (set _verb=0&set _rtr=ReturnHook&goto :InstallHook):ReturnHookif %External% EQU 0 if %_AUR% EQU 1 (call :UpdateIFEOEntry %SppVer%call :UpdateIFEOEntry osppsvc.exe)if %External% EQU 1 if %_AUR% EQU 1 (call :UpdateOSPPEntry osppsvc.exe)SET Win10Gov=0SET "EditionWMI="SET "EditionID="IF %winbuild% LSS 14393 if %SSppHook% NEQ 0 GOTO :MainSET "RegKey=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages"SET "Pattern=Microsoft-Windows-*Edition~31bf3856ad364e35"SET "EditionPKG=FFFFFFFF"FOR /F "TOKENS=8 DELIMS=\" %%A IN ('REG QUERY "%RegKey%" /f "%Pattern%" /k %_Nul6% ^| FIND /I "CurrentVersion"') DO (REG QUERY "%RegKey%\%%A" /v "CurrentState" %_Nul2% | FIND /I "0x70" %_Nul1% && (FOR /F "TOKENS=3 DELIMS=-~" %%B IN ('ECHO %%A') DO SET "EditionPKG=%%B"))IF /I "%EditionPKG:~-7%"=="Edition" (SET "EditionID=%EditionPKG:~0,-7%") ELSE (FOR /F "TOKENS=3 DELIMS=: " %%A IN ('DISM /English /Online /Get-CurrentEdition %_Nul6% ^| FIND /I "Current Edition :"') DO SET "EditionID=%%A")net start sppsvc /y %_Nul3%FOR /F "TOKENS=2 DELIMS==" %%A IN ('"WMIC PATH SoftwareLicensingProduct WHERE (ApplicationID='%_wApp%' %adoff% AND PartialProductKey is not NULL) GET LicenseFamily /VALUE" %_Nul6%') DO SET "EditionWMI=%%A"IF "%EditionWMI%"=="" (IF %winbuild% GEQ 17063 FOR /F "SKIP=2 TOKENS=2*" %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionId') DO SET "EditionID=%%B"IF %winbuild% LSS 14393 (FOR /F "SKIP=2 TOKENS=2*" %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionId') DO SET "EditionID=%%B"GOTO :Main))IF NOT "%EditionWMI%"=="" SET "EditionID=%EditionWMI%"IF /I "%EditionID%"=="IoTEnterprise" SET "EditionID=Enterprise"IF /I "%EditionID%"=="IoTEnterpriseS" SET "EditionID=EnterpriseS"IF /I "%EditionID%"=="ProfessionalSingleLanguage" SET "EditionID=Professional"IF /I "%EditionID%"=="ProfessionalCountrySpecific" SET "EditionID=Professional"IF /I "%EditionID%"=="EnterpriseG" SET Win10Gov=1IF /I "%EditionID%"=="EnterpriseGN" SET Win10Gov=1:Mainif defined EditionID (set "_winos=Windows %EditionID% edition") else (set "_winos=检测到 Windows")for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName %_Nul6%') do if not errorlevel 1 set "_winos=%%b"set "nKMS=不支持 KMS 激活……"set "nEval=评估版本无法激活。请安装 Windows 操作系统的完整版本。"if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" set _eval=1if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*EvalEdition~*.mum" set "nEval=Server 评估版本无法激活。请转换为完整的 Server 操作系统。"if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*EvalCorEdition~*.mum" set _eval=1&set "nEval=Server 评估版本无法激活。请转换为完整的 Server 操作系统。"set "_C16R="reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath %_Nul3% && for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath" %_Nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %_Nul3% && set "_C16R=HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration")if not defined _C16R reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun /v InstallPath %_Nul3% && for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun /v InstallPath" %_Nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %_Nul3% && set "_C16R=HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\Configuration")set "_C15R="reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun /v InstallPath %_Nul3% && for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun /v InstallPath" %_Nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration /v ProductReleaseIds %_Nul3% && call set "_C15R=HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration"if not defined _C15R reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\propertyBag /v productreleaseid %_Nul3% && call set "_C15R=HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\propertyBag")set "_C14R="if %_wow%==0 (reg query HKLM\SOFTWARE\Microsoft\Office\14.0\CVH /f Click2run /k %_Nul3% && set "_C14R=1") else (reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\CVH /f Click2run /k %_Nul3% && set "_C14R=1")for %%A in (14,15,16,19,21) do call :officeLoc %%Aif %_O14MSI% EQU 1 set "_C14R="set S_OK=1call :RunSPPif %ActOffice% NEQ 0 call :RunOSPPif %ActOffice% EQU 0 (echo.&echo Office 激活已关闭……)if %S_OK% EQU 0 if %External% EQU 0 call :CheckFRif exist "!_temp!\crv*.txt" del /f /q "!_temp!\crv*.txt"if exist "!_temp!\*chk.txt" del /f /q "!_temp!\*chk.txt"if exist "!_temp!\slmgr.vbs" del /f /q "!_temp!\slmgr.vbs"call :StopService sppsvcif %OsppHook% NEQ 0 call :StopService osppsvcif %_AUR% EQU 0 call :RemoveHooksc start sppsvc trigger=timer;sessionid=0 %_Nul3%if %_verb% EQU 1 (echo.&echo %line3%&echo.if %External% EQU 0 if "%_rtr%"=="DoActivate" (echo.echo 请确保在防病毒保护中排除此文件。echo %SystemRoot%\System32\SppExtComObjHook.dll))set External=0set KMS_IP=%_uIP%if %uManual% EQU 1 timeout 5if %uAutoRenewal% EQU 1 timeout 5if %Unattend% NEQ 0 goto :TheEndecho.echo 请按任意键继续执行……pause >nulgoto :MainMenu:RunSPPset spp=SoftwareLicensingProductset sps=SoftwareLicensingServiceset W1nd0ws=1set WinPerm=0set WinVL=0set Off1ce=0set RunR2V=0set aC2R21=0set aC2R19=0set aC2R16=0set aC2R15=0if %winbuild% GEQ 9200 if %ActOffice% NEQ 0 call :sppoffwmic path %spp% where (Description like '%%KMSCLIENT%%') get Name /value %_Nul2% | findstr /i Windows %_Nul1% && (set WinVL=1)if %WinVL% EQU 0 (if %ActWindows% EQU 0 (echo.&echo Windows 激活已关闭……) else (if %SSppHook% EQU 0 (echo.&echo %_winos% %nKMS%if defined _eval echo %nEval%) else (echo.&echo 检查 Windows 的 KMS 激活 ID 失败。&echo spsppsvc 服务或 SppExtComObjHook.dll 均不可使用。&echo 请参阅“自述文件”了解疑难解答。exit /b)))if %WinVL% EQU 0 if %Off1ce% EQU 0 exit /bif %_AUR% EQU 0 (reg delete "HKLM\%SPPk%\%_wApp%" /f %_Null%rem reg delete "HKLM\%SPPk%\%_oApp%" /f %_Null%reg delete "HKU\S-1-5-20\%SPPk%\%_wApp%" /f %_Null%reg delete "HKU\S-1-5-20\%SPPk%\%_oApp%" /f %_Null%)set _gvlk=0if %winbuild% GEQ 10240 wmic path %spp% where (ApplicationID='%_wApp%' and Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL) get Name /value %_Nul2% | findstr /i Windows %_Nul1% && (set _gvlk=1)set gpr=0if %winbuild% GEQ 10240 if %SkipKMS38% NEQ 0 if %_gvlk% EQU 1 for /f "tokens=2 delims==" %%A in ('"wmic path %spp% where (ApplicationID='%_wApp%' and Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL) get GracePeriodRemaining /VALUE" %_Nul6%') do set "gpr=%%A"if %gpr% NEQ 0 if %gpr% GTR 259200 (set W1nd0ws=0wmic path %spp% where "ApplicationID='%_wApp%' and Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL" get LicenseFamily /value %_Nul2% | findstr /i EnterpriseG %_Nul1% && (call set W1nd0ws=1))for /f "tokens=2 delims==" %%A in ('"wmic path %sps% get Version /VALUE"') do set ver=%%Areg add "HKLM\%SPPk%" /f /v KeyManagementServiceName /t REG_SZ /d "%KMS_IP%" %_Nul3%reg add "HKLM\%SPPk%" /f /v KeyManagementServicePort /t REG_SZ /d "%KMS_Port%" %_Nul3%if %winbuild% GEQ 9200 (if not %xOS%==x86 (reg add "HKLM\%SPPk%" /f /v KeyManagementServiceName /t REG_SZ /d "%KMS_IP%" /reg:32 %_Nul3%reg add "HKLM\%SPPk%" /f /v KeyManagementServicePort /t REG_SZ /d "%KMS_Port%" /reg:32 %_Nul3%reg delete "HKLM\%SPPk%\%_oApp%" /f /reg:32 %_Null%reg add "HKLM\%SPPk%\%_oApp%" /f /v KeyManagementServiceName /t REG_SZ /d "%KMS_IP%" /reg:32 %_Nul3%reg add "HKLM\%SPPk%\%_oApp%" /f /v KeyManagementServicePort /t REG_SZ /d "%KMS_Port%" /reg:32 %_Nul3%)reg delete "HKLM\%SPPk%\%_oApp%" /f %_Null%reg add "HKLM\%SPPk%\%_oApp%" /f /v KeyManagementServiceName /t REG_SZ /d "%KMS_IP%" %_Nul3%reg add "HKLM\%SPPk%\%_oApp%" /f /v KeyManagementServicePort /t REG_SZ /d "%KMS_Port%" %_Nul3%)if %W1nd0ws% EQU 0 for /f "tokens=2 delims==" %%G in ('"wmic path %spp% where (ApplicationID='%_wApp%' and Description like '%%KMSCLIENT%%') get ID /VALUE"') do (set app=%%G&call :sppchkwin)if %W1nd0ws% EQU 1 if %ActWindows% NEQ 0 for /f "tokens=2 delims==" %%G in ('"wmic path %spp% where (ApplicationID='%_wApp%' and Description like '%%KMSCLIENT%%' %adoff%) get ID /VALUE"') do (set app=%%G&call :sppchkwin)rem if %ESU_EDT% EQU 1 if %ActWindows% NEQ 0 for /f "tokens=2 delims==" %%G in ('"wmic path %spp% where (ApplicationID='%_wApp%' and Description like '%%KMSCLIENT%%' %addon%) get ID /VALUE"') do (set app=%%G&call :esuchk)if %W1nd0ws% EQU 1 if %ActWindows% EQU 0 (echo.&echo Windows 激活已关闭……)if %Off1ce% EQU 1 if %ActOffice% NEQ 0 for /f "tokens=2 delims==" %%G in ('"wmic path %spp% where (ApplicationID='%_oApp%' and Description like '%%KMSCLIENT%%') get ID /VALUE"') do (set app=%%G&call :sppchkoff)if %_AUR% EQU 0 (call :cREG %_Nul3%) else (reg delete "HKLM\%SPPk%" /f /v DisableDnsPublishing %_Null%reg delete "HKLM\%SPPk%" /f /v DisableKeyManagementServiceHostCaching %_Null%)exit /b:sppoffset OffUWP=0if %winbuild% GEQ 10240 reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msoxmled.exe" %_Nul3% && (dir /b "%ProgramFiles%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set OffUWP=1if not %xOS%==x86 dir /b "%ProgramW6432%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set OffUWP=1)rem 无已安装的方案if %loc_off21% EQU 0 if %loc_off19% EQU 0 if %loc_off16% EQU 0 if %loc_off15% EQU 0 (if %OffUWP% EQU 0 (echo.&echo 未检测到已安装的 Office 2013-2021 产品……) else (echo.&echo %_mOuwp%)exit /b)set Off1ce=1set _sC2R=sppoffset _fC2R=ReturnSPPset vol_off15=0&set vol_off16=0&set vol_off19=0&set vol_off21=0wmic path %spp% where (Description like '%%KMSCLIENT%%' AND NOT Name like '%%MondoR_KMS_Automation%%') get Name /value > "!_temp!\sppchk.txt" 2>&1find /i "Office 21" "!_temp!\sppchk.txt" %_Nul1% && (set vol_off21=1)find /i "Office 19" "!_temp!\sppchk.txt" %_Nul1% && (set vol_off19=1)find /i "Office 16" "!_temp!\sppchk.txt" %_Nul1% && (set vol_off16=1)find /i "Office 15" "!_temp!\sppchk.txt" %_Nul1% && (set vol_off15=1)for %%A in (15,16,19,21) do if !loc_off%%A! EQU 0 set vol_off%%A=0if %vol_off16% EQU 1 find /i "Office16MondoVL_KMS_Client" "!_temp!\sppchk.txt" %_Nul1% && (wmic path %spp% where 'ApplicationID="%_oApp%" AND LicenseFamily like "Office16O365%%"' get LicenseFamily /value %_Nul2% | find /i "O365" %_Nul1% || (set vol_off16=0))if %vol_off15% EQU 1 find /i "OfficeMondoVL_KMS_Client" "!_temp!\sppchk.txt" %_Nul1% && (wmic path %spp% where 'ApplicationID="%_oApp%" AND LicenseFamily like "OfficeO365%%"' get LicenseFamily /value %_Nul2% | find /i "O365" %_Nul1% || (set vol_off15=0))set ret_off15=0&set ret_off16=0&set ret_off19=0&set ret_off21=0wmic path %spp% where (ApplicationID='%_oApp%' AND NOT Name like '%%O365%%') get Name /value > "!_temp!\sppchk.txt" 2>&1find /i "R_Retail" "!_temp!\sppchk.txt" %_Nul2% | find /i "Office 21" %_Nul1% && (set ret_off21=1)find /i "R_Retail" "!_temp!\sppchk.txt" %_Nul2% | find /i "Office 19" %_Nul1% && (set ret_off19=1)find /i "R_Retail" "!_temp!\sppchk.txt" %_Nul2% | find /i "Office 16" %_Nul1% && (set ret_off16=1)find /i "R_Retail" "!_temp!\sppchk.txt" %_Nul2% | find /i "Office 15" %_Nul1% && (set ret_off15=1)if %ret_off21% EQU 1 if %_O16MSI% EQU 0 set vol_off21=0if %ret_off19% EQU 1 if %_O16MSI% EQU 0 set vol_off19=0if %ret_off16% EQU 1 if %_O16MSI% EQU 0 set vol_off16=0if %ret_off15% EQU 1 if %_O15MSI% EQU 0 set vol_off15=0set run_off16=0if defined _C16R if %loc_off16% EQU 1 if %vol_off16% EQU 0 if %ret_off16% EQU 1 (for %%a in (%DO16Ids%) do find /i "Office16%%aR" "!_temp!\sppchk.txt" %_Nul1% && (if %vol_off21% EQU 1 find /i "Office21%%a2021VL" "!_temp!\sppchk.txt" %_Nul1% || set run_off16=1if %vol_off19% EQU 1 find /i "Office19%%a2019VL" "!_temp!\sppchk.txt" %_Nul1% || set run_off16=1)for %%a in (Professional) do find /i "Office16%%aR" "!_temp!\sppchk.txt" %_Nul1% && (if %vol_off21% EQU 1 find /i "Office21ProPlus2021VL" "!_temp!\sppchk.txt" %_Nul1% || set run_off16=1if %vol_off19% EQU 1 find /i "Office19ProPlus2019VL" "!_temp!\sppchk.txt" %_Nul1% || set run_off16=1)for %%a in (HomeBusiness,HomeStudent) do find /i "Office16%%aR" "!_temp!\sppchk.txt" %_Nul1% && (if %vol_off21% EQU 1 find /i "Office21Standard2021VL" "!_temp!\sppchk.txt" %_Nul1% || set run_off16=1if %vol_off19% EQU 1 find /i "Office19Standard2019VL" "!_temp!\sppchk.txt" %_Nul1% || set run_off16=1))if defined _C16R if %loc_off16% EQU 1 if %run_off16% EQU 0 wmic path %spp% where (ApplicationID='%_oApp%' AND LicenseFamily like 'Office16O365%%') get LicenseFamily /value %_Nul2% | find /i "O365" %_Nul1% && (find /i "Office16MondoVL" "!_temp!\sppchk.txt" %_Nul1% || set run_off16=1)set vol_offgl=1if %vol_off21% EQU 0 if %vol_off19% EQU 0 if %vol_off16% EQU 0 if %vol_off15% EQU 0 set vol_offgl=0rem 混合批量版本 + 零售版本方案if %loc_off21% EQU 1 if %vol_off21% EQU 0 if %RunR2V% EQU 0 if %AutoR2V% EQU 1 goto :C2RR2Vif %loc_off19% EQU 1 if %vol_off19% EQU 0 if %RunR2V% EQU 0 if %AutoR2V% EQU 1 goto :C2RR2Vif defined _C16R if %loc_off16% EQU 1 if %vol_off16% EQU 0 if %RunR2V% EQU 0 if %AutoR2V% EQU 1 if %run_off16% EQU 1 goto :C2RR2Vif defined _C15R if %loc_off15% EQU 1 if %vol_off15% EQU 0 if %RunR2V% EQU 0 if %AutoR2V% EQU 1 goto :C2RR2Vif %loc_off16% EQU 0 if %ret_off16% EQU 1 if %_O16MSI% EQU 0 if %OffUWP% EQU 1 (echo.&echo %_mOuwp%)rem 所有支持的