This commit is contained in:
abbodi1406 2021-11-03 12:27:01 +03:00
commit 2f00456045
4 changed files with 637 additions and 174 deletions

View file

@ -1,10 +1,7 @@
<!-- : Begin batch script
@setlocal DisableDelayedExpansion
@set uivr=v13 AIO
@set uivr=v15
@echo off
:: Licenses used for converting Office 365 ProPlus:
:: set _O365asO2019=0 -> use Office 2016 Mondo (if you want some Office 365 features)
:: set _O365asO2019=1 -> use Office 2019 ProPlus (only for Windows 7 and 8.1)
set _O365asO2019=0
:: set to 1 to enable debug mode
set _Debug=0
@ -12,19 +9,36 @@ set _Debug=0
:: set to 0 to enable debug mode without cleaning or converting
set _Cnvrt=1
:: set to 1 to use VBScript instead wmic.exe to access WMI
:: this option is automatically enabled for Windows 11 build 22483 and later
set WMI_VBS=0
:: ##################################################################
set "_cmdf=%~f0"
if exist "%SystemRoot%\Sysnative\cmd.exe" (
setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" "
exit /b
)
if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 (
setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" "
exit /b
)
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 "_ln============================================================="
set "_err===== ERROR ===="
set "_psc=powershell -noprofile -exec bypass -c"
set "xBit=x64"
if /i %PROCESSOR_ARCHITECTURE%==x86 (if not defined PROCESSOR_ARCHITEW6432 (
set "xBit=x86"
)
)
if /i "%PROCESSOR_ARCHITECTURE%"=="amd64" set "xBit=x64"
if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" set "xBit=x86"
if /i "%PROCESSOR_ARCHITECTURE%"=="x86" if "%PROCESSOR_ARCHITEW6432%"=="" set "xBit=x86"
if /i "%PROCESSOR_ARCHITEW6432%"=="amd64" set "xBit=x64"
if /i "%PROCESSOR_ARCHITEW6432%"=="arm64" set "xBit=x86"
:: set "_psc=powershell -noprofile -c"
:: if not exist "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" goto :E_PS
if %_Cnvrt% NEQ 1 set _Debug=1
@ -35,6 +49,7 @@ goto :TheEnd
)
:Passed
set "_Local=%LocalAppData%"
set "_batf=%~f0"
set "_batp=%_batf:'=''%"
set "_log=%~dpn0"
@ -42,6 +57,34 @@ set "_work=%~dp0"
if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%"
for /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"
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set "_csq=cscript.exe //NoLogo //Job:WmiQuery "%~nx0?.wsf""
set "_csm=cscript.exe //NoLogo //Job:WmiMethod "%~nx0?.wsf""
set "_csp=cscript.exe //NoLogo //Job:WmiPKey "%~nx0?.wsf""
if %winbuild% GEQ 22483 set WMI_VBS=1
if %WMI_VBS% EQU 0 (
set "_zz1=wmic path"
set "_zz2=where"
set "_zz3=get"
set "_zz4=/value"
set "_zz5=("
set "_zz6=)"
set "_zz7="wmic path"
set "_zz8=/value""
) else (
set "_zz1=%_csq%"
set "_zz2="
set "_zz3="
set "_zz4="
set "_zz5=""
set "_zz6=""
set "_zz7=%_csq%"
set "_zz8="
)
set _WSH=1
reg query "HKCU\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0)
reg query "HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0)
if %_WSH% EQU 0 if %WMI_VBS% NEQ 0 goto :E_VBS
setlocal EnableDelayedExpansion
if %_Debug% EQU 0 (
@ -74,7 +117,6 @@ if %_Debug% EQU 0 (
:Begin
color 1F
title Office Click-to-Run Retail-to-Volume %uivr%
for /f "tokens=6 delims=[]. " %%# in ('ver') do set winbuild=%%#
set "_SLMGR=%SysPath%\slmgr.vbs"
set "_oApp=0ff1ce15-a989-479d-af46-f275c6370663"
if %_Debug% EQU 0 (
@ -82,6 +124,8 @@ set "_cscript=cscript //Nologo //B"
) else (
set "_cscript=cscript //Nologo"
)
set _LTSC=0
set "_tag="&set "_ons= 2016"
echo %_ln%
echo Running C2R-R2V %uivr%
@ -104,12 +148,18 @@ set _Office16=0
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" (
set _Office16=1
)
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" (
set _Office16=1
)
set _Office15=0
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" (
set _Office15=1
)
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun /v InstallPath" %_Nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (
set _Office15=1
)
if %_Office16% EQU 0 if %_Office15% EQU 0 (
set "msg=No installed Office 2013/2016/2019 product detected..."
set "msg=No installed Office 2013-2021 product detected..."
goto :TheEnd
)
@ -117,52 +167,80 @@ goto :TheEnd
if %_Office16% EQU 0 goto :Reg15istry
set "_InstallRoot="
set "_ProductIds="
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath" %_Nul6%') do if not errorlevel 1 (set "_InstallRoot=%%b\root")
set "_GUID="
set "_Config="
set "_PRIDs="
set "_LicensesPath="
set "_Integrator="
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath" %_Nul6%') do (set "_InstallRoot=%%b\root")
if not "%_InstallRoot%"=="" (
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v PackageGUID" %_Nul6%') do if not errorlevel 1 (set "_GUID=%%b")
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds" %_Nul6%') do if not errorlevel 1 (set "_ProductIds=%%b")
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v PackageGUID" %_Nul6%') do (set "_GUID=%%b")
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds" %_Nul6%') do (set "_ProductIds=%%b")
set "_Config=HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration"
set "_PRIDs=HKLM\SOFTWARE\Microsoft\Office\ClickToRun\ProductReleaseIDs"
) else (
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun /v InstallPath" %_Nul6%') do (set "_InstallRoot=%%b\root")
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun /v PackageGUID" %_Nul6%') do (set "_GUID=%%b")
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds" %_Nul6%') do (set "_ProductIds=%%b")
set "_Config=HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\Configuration"
set "_PRIDs=HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\ProductReleaseIDs"
)
set "_LicensesPath=%_InstallRoot%\Licenses16"
set "_Integrator=%_InstallRoot%\integration\integrator.exe"
for /f "skip=2 tokens=2*" %%a in ('"reg query %_PRIDs% /v ActiveConfiguration" %_Nul6%') do set "_PRIDs=%_PRIDs%\%%b"
if "%_ProductIds%"=="" (
set "msg=Could not detect Office 2016/2019 ProductIDs..."
set "msg=Could not detect Office 2016-2021 ProductIDs..."
if %_Office15% EQU 0 (goto :TheEnd) else (goto :Reg15istry)
)
if not exist "%_LicensesPath%\ProPlus*.xrm-ms" (
set "msg=Could not detect Office 2016/2019 Licenses files..."
set "msg=Could not detect Office 2016-2021 Licenses files..."
if %_Office15% EQU 0 (goto :TheEnd) else (goto :Reg15istry)
)
if not exist "%_Integrator%" (
set "msg=Could not detect Office 2016/2019 Licenses Integrator..."
set "msg=Could not detect Office 2016-2021 Licenses Integrator..."
if %_Office15% EQU 0 (goto :TheEnd) else (goto :Reg15istry)
)
if %winbuild% GEQ 10240 set _O365asO2019=0
if exist "%_LicensesPath%\Word2019VL_KMS_Client_AE*.xrm-ms" (set "_tag=2019"&set "_ons= 2019") else (set "_tag="&set "_ons= 2016")
if exist "%_LicensesPath%\Word2019VL_KMS_Client_AE*.xrm-ms" (set "_tag=2019"&set "_ons= 2019")
if exist "%_LicensesPath%\Word2021VL_KMS_Client_AE*.xrm-ms" (set _LTSC=1)
if %winbuild% LSS 10240 if !_LTSC! EQU 1 (set "_tag=2021"&set "_ons= 2021")
if %_Office15% EQU 0 goto :CheckC2R
:Reg15istry
set "_Install15Root="
set "_Product15Ids="
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun /v InstallPath" %_Nul6%') do if not errorlevel 1 (set "_Install15Root=%%b\root")
set "_Con15fig="
set "_PR15IDs="
set "_OSPP15Ready="
set "_Licenses15Path="
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun /v InstallPath" %_Nul6%') do (set "_Install15Root=%%b\root")
if not "%_Install15Root%"=="" (
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun /v PackageGUID" %_Nul6%') do if not errorlevel 1 (set "_GU15ID=%%b")
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration /v ProductReleaseIds" %_Nul6%') do if not errorlevel 1 (set "_Product15Ids=%%b")
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration /v ProductReleaseIds" %_Nul6%') do (set "_Product15Ids=%%b")
set "_Con15fig=HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration /v ProductReleaseIds"
set "_PR15IDs=HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\ProductReleaseIDs"
set "_OSPP15Ready=HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration"
) else (
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun /v InstallPath" %_Nul6%') do (set "_Install15Root=%%b\root")
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun\Configuration /v ProductReleaseIds" %_Nul6%') do (set "_Product15Ids=%%b")
set "_Con15fig=HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun\Configuration /v ProductReleaseIds"
set "_PR15IDs=HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun\ProductReleaseIDs"
set "_OSPP15Ready=HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun\Configuration"
)
set "_OSPP15ReadT=REG_SZ"
if "%_Product15Ids%"=="" (
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\propertyBag /v productreleaseid" %_Nul6%') do if not errorlevel 1 (set "_Product15Ids=%%b")
reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\propertyBag /v productreleaseid %_Nul3% && (
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\propertyBag /v productreleaseid" %_Nul6%') do (set "_Product15Ids=%%b")
set "_Con15fig=HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\propertyBag /v productreleaseid"
set "_OSPP15Ready=HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun"
set "_OSPP15ReadT=REG_DWORD"
)
reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun\propertyBag /v productreleaseid %_Nul3% && (
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun\propertyBag /v productreleaseid" %_Nul6%') do (set "_Product15Ids=%%b")
set "_Con15fig=HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun\propertyBag /v productreleaseid"
set "_OSPP15Ready=HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun"
set "_OSPP15ReadT=REG_DWORD"
)
)
set "_Licenses15Path=%_Install15Root%\Licenses"
set "_Integ15rator=%_Install15Root%\integration\integrator.exe"
if exist "%ProgramFiles%\Microsoft Office\Office15\OSPP.VBS" (
set "_OSPP15VBS=%ProgramFiles%\Microsoft Office\Office15\OSPP.VBS"
) else if exist "%ProgramW6432%\Microsoft Office\Office15\OSPP.VBS" (
@ -203,7 +281,8 @@ set _sps=OfficeSoftwareProtectionService
set _vbsi="!_OSPP15VBS!" /inslic:
)
set "_wmi="
for /f "tokens=2 delims==" %%# in ('"wmic path %_sps% get version /value" %_Nul6%') do set "_wmi=%%#"
set "_qr=%_zz7% %_sps% %_zz3% Version %_zz8%"
for /f "tokens=2 delims==" %%# in ('%_qr%') do set _wmi=%%#
if "%_wmi%"=="" (
set "msg=Could not execute %_sps% WMI..."
goto :TheEnd
@ -212,23 +291,53 @@ echo.
echo %_ln%
echo Checking Office Licenses...
echo %_ln%
wmic path %_spp% where "ApplicationID='%_oApp%' AND Description like '%%KMSCLIENT%%'" get LicenseFamily %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _KMS=1) || (set _KMS=0)
wmic path %_spp% where "ApplicationID='%_oApp%' AND Description like '%%TIMEBASED%%'" get LicenseFamily %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _Time=1) || (set _Time=0)
wmic path %_spp% where "ApplicationID='%_oApp%' AND Description like '%%Trial%%'" get LicenseFamily %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _Time=1)
wmic path %_spp% where "ApplicationID='%_oApp%' AND Description like '%%Grace%%'" get LicenseFamily %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _Grace=1) || (set _Grace=0)
if %_Office16% EQU 1 wmic path %_spp% where "ApplicationID='%_oApp%'" get LicenseFamily %_Nul2% | find /i "Office16MondoVL_KMS_Client" %_Nul1% && (
wmic path %_spp% where "ApplicationID='%_oApp%' AND LicenseFamily like 'Office16O365%%'" get LicenseFamily %_Nul2% | find /i "O365" %_Nul1% || (set _Grace=1)
set "_qr=%_zz1% %_spp% %_zz2% %_zz5%ApplicationID='%_oApp%' AND Description like '%%KMSCLIENT%%' %_zz6% %_zz3% LicenseFamily %_zz4%"
%_qr% %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _KMS=1) || (set _KMS=0)
set "_qr=%_zz1% %_spp% %_zz2% %_zz5%ApplicationID='%_oApp%' AND Description like '%%TIMEBASED%%' %_zz6% %_zz3% LicenseFamily %_zz4%"
%_qr% %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _Time=1) || (set _Time=0)
set "_qr=%_zz1% %_spp% %_zz2% %_zz5%ApplicationID='%_oApp%' AND Description like '%%Trial%%' %_zz6% %_zz3% LicenseFamily %_zz4%"
%_qr% %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _Time=1)
set "_qr=%_zz1% %_spp% %_zz2% %_zz5%ApplicationID='%_oApp%' AND Description like '%%Grace%%' %_zz6% %_zz3% LicenseFamily %_zz4%"
%_qr% %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _Grace=1) || (set _Grace=0)
set "_qr=%_zz1% %_spp% %_zz2% "ApplicationID='%_oApp%'" %_zz3% LicenseFamily %_zz4%"
%_qr% > "!_temp!\crvchk.txt" 2>&1
set "_qr=%_zz1% %_spp% %_zz2% "ApplicationID='%_oApp%' AND LicenseFamily like 'Office16O365%%'" %_zz3% LicenseFamily %_zz4%"
if %_Office16% EQU 1 find /i "Office16MondoVL_KMS_Client" "!_temp!\crvchk.txt" %_Nul1% && (
%_qr% %_Nul2% | find /i "O365" %_Nul1% || (set _Grace=1)
)
if %_Office15% EQU 1 wmic path %_spp% where "ApplicationID='%_oApp%'" get LicenseFamily %_Nul2% | find /i "OfficeMondoVL_KMS_Client" %_Nul1% && (
wmic path %_spp% where "ApplicationID='%_oApp%' AND LicenseFamily like 'OfficeO365%%'" get LicenseFamily %_Nul2% | find /i "O365" %_Nul1% || (set _Grace=1)
set "_qr=%_zz1% %_spp% %_zz2% "ApplicationID='%_oApp%' AND LicenseFamily like 'OfficeO365%%'" %_zz3% LicenseFamily %_zz4%"
if %_Office15% EQU 1 find /i "OfficeMondoVL_KMS_Client" "!_temp!\crvchk.txt" %_Nul1% && (
%_qr% %_Nul2% | find /i "O365" %_Nul1% || (set _Grace=1)
)
if %_Time% EQU 0 if %_Grace% EQU 0 if %_KMS% EQU 1 (
set "msg=No Conversion or Cleanup Required..."
goto :TheEnd
)
set _Identity=0
set _vNext=0
set sub_O365=0
set sub_proj=0
set sub_vis=0
dir /b /s /a:-d "!_Local!\Microsoft\Office\Licenses\*1*" %_Nul3% && set _Identity=1
dir /b /s /a:-d "!ProgramData!\Microsoft\Office\Licenses\*1*" %_Nul3% && set _Identity=1
set kNext=HKCU\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext
if %_Identity% EQU 1 reg query %kNext% /v MigrationToV5Done %_Nul2% | find /i "0x1" %_Nul1% && set _vNext=1
if %_vNext% EQU 1 (
reg query %kNext% | findstr /i /r ".*retail" %_Nul2% | findstr /i /v "project visio" %_Nul2% | find /i "0x2" %_Nul1% && (set sub_O365=1)
reg query %kNext% | findstr /i /r ".*retail" %_Nul2% | findstr /i /v "project visio" %_Nul2% | find /i "0x3" %_Nul1% && (set sub_O365=1)
reg query %kNext% | findstr /i /r ".*volume" %_Nul2% | findstr /i /v "project visio" %_Nul2% | find /i "0x2" %_Nul1% && (set sub_O365=1)
reg query %kNext% | findstr /i /r ".*volume" %_Nul2% | findstr /i /v "project visio" %_Nul2% | find /i "0x3" %_Nul1% && (set sub_O365=1)
reg query %kNext% | findstr /i /r "project.*" %_Nul2% | find /i "0x2" %_Nul1% && set sub_proj=1
reg query %kNext% | findstr /i /r "project.*" %_Nul2% | find /i "0x3" %_Nul1% && set sub_proj=1
reg query %kNext% | findstr /i /r "visio.*" %_Nul2% | find /i "0x2" %_Nul1% && set sub_vis=1
reg query %kNext% | findstr /i /r "visio.*" %_Nul2% | find /i "0x3" %_Nul1% && set sub_vis=1
)
set _Retail=0
wmic path %_spp% where "ApplicationID='%_oApp%' AND LicenseStatus='1' AND PartialProductKey<>NULL" get Description %_Nul2% |findstr /V /R "^$" >"!_temp!\crvRetail.txt"
set "_ocq=ApplicationID='%_oApp%' AND LicenseStatus='1' AND PartialProductKey is not NULL"
if %WMI_VBS% EQU 0 wmic path %_spp% where (%_ocq%) get Description %_Nul2% |findstr /V /R "^$" >"!_temp!\crvRetail.txt"
set "_qr=%_csq% %_spp% "%_ocq%" Description"
if %WMI_VBS% NEQ 0 %_qr% %_Nul2% >"!_temp!\crvRetail.txt"
find /i "RETAIL channel" "!_temp!\crvRetail.txt" %_Nul1% && set _Retail=1
find /i "RETAIL(MAK) channel" "!_temp!\crvRetail.txt" %_Nul1% && set _Retail=1
find /i "TIMEBASED_SUB channel" "!_temp!\crvRetail.txt" %_Nul1% && set _Retail=1
@ -249,7 +358,7 @@ set xBit=x86
set _copp="!_Install15Root!\vfs\SystemX86"
set xBit=x86
)
if %_Cnvrt% EQU 1 if %_Retail% EQU 0 if %_OMSI% EQU 0 if defined _copp (
if %_Cnvrt% EQU 1 if %_Identity% EQU 0 if %_Retail% EQU 0 if %_OMSI% EQU 0 if defined _copp (
echo.
echo %_ln%
echo Cleaning Current Office Licenses...
@ -272,23 +381,35 @@ popd
:PassCopp
echo.
echo %_ln%
echo Installing Office Volume Licenses...
echo Checking installed Office Products...
echo %_ln%
echo.
set _O16O365=0
if %_Retail% EQU 1 wmic path %_spp% where "ApplicationID='%_oApp%' AND LicenseStatus='1' AND PartialProductKey<>NULL" get LicenseFamily %_Nul2% |findstr /V /R "^$" >"!_temp!\crvRetail.txt"
wmic path %_spp% where "ApplicationID='%_oApp%'" get LicenseFamily %_Nul2% |findstr /V /R "^$" >"!_temp!\crvVolume.txt" 2>&1
set _C16Msg=0
set _C15Msg=0
set "_qr=%_csq% %_spp% "%_ocq%" LicenseFamily"
if %_Retail% EQU 1 if %WMI_VBS% EQU 0 wmic path %_spp% where (%_ocq%) get LicenseFamily %_Nul2% |findstr /V /R "^$" >"!_temp!\crvRetail.txt"
if %_Retail% EQU 1 if %WMI_VBS% NEQ 0 %_qr% %_Nul2% >"!_temp!\crvRetail.txt"
set "_qr=%_csq% %_spp% "ApplicationID='%_oApp%'" LicenseFamily"
if %WMI_VBS% EQU 0 wmic path %_spp% where "ApplicationID='%_oApp%'" get LicenseFamily %_Nul2% |findstr /V /R "^$" >"!_temp!\crvVolume.txt" 2>&1
if %WMI_VBS% NEQ 0 %_qr% %_Nul2% >"!_temp!\crvVolume.txt" 2>&1
if %_Office16% EQU 0 goto :R15V
set _O21Ids=ProPlus2021,ProjectPro2021,VisioPro2021,Standard2021,ProjectStd2021,VisioStd2021,Access2021,SkypeforBusiness2021
set _O19Ids=ProPlus2019,ProjectPro2019,VisioPro2019,Standard2019,ProjectStd2019,VisioStd2019,Access2019,SkypeforBusiness2019
set _O16Ids=ProjectPro,VisioPro,Standard,ProjectStd,VisioStd,Access,SkypeforBusiness
set _A21Ids=Excel2021,Outlook2021,PowerPoint2021,Publisher2021,Word2021
set _A19Ids=Excel2019,Outlook2019,PowerPoint2019,Publisher2019,Word2019
set _A16Ids=Excel,Outlook,PowerPoint,Publisher,Word
set _V21Ids=%_O21Ids%,%_A21Ids%
set _V19Ids=%_O19Ids%,%_A19Ids%
set _V16Ids=Mondo,%_O16Ids%,%_A16Ids%,OneNote
set _R16Ids=%_V16Ids%,Professional,HomeBusiness,HomeStudent,O365ProPlus,O365Business,O365SmallBusPrem,O365HomePrem,O365EduCloud
set _RetIds=%_V19Ids%,Professional2019,HomeBusiness2019,HomeStudent2019,%_R16Ids%
set _RetIds=%_V21Ids%,Professional2021,HomeBusiness2021,HomeStudent2021,%_V19Ids%,Professional2019,HomeBusiness2019,HomeStudent2019,%_R16Ids%
set _Suites=Mondo,O365ProPlus,O365Business,O365SmallBusPrem,O365HomePrem,O365EduCloud,ProPlus,Standard,Professional,HomeBusiness,HomeStudent,ProPlus2019,Standard2019,Professional2019,HomeBusiness2019,HomeStudent2019,ProPlus2021,Standard2021,Professional2021,HomeBusiness2021,HomeStudent2021
set _PrjSKU=ProjectPro,ProjectStd,ProjectPro2019,ProjectStd2019,ProjectPro2021,ProjectStd2021
set _VisSKU=VisioPro,VisioStd,VisioPro2019,VisioStd2019,VisioPro2021,VisioStd2021
echo %_ProductIds%>"!_temp!\crvProductIds.txt"
for %%a in (%_RetIds%,ProPlus) do (
@ -297,6 +418,14 @@ set _%%a=0
for %%a in (%_RetIds%) do (
findstr /I /C:"%%aRetail" "!_temp!\crvProductIds.txt" %_Nul1% && set _%%a=1
)
if !_LTSC! EQU 0 for %%a in (%_V21Ids%) do (
set _%%a=0
)
if !_LTSC! EQU 1 for %%a in (%_V21Ids%) do (
findstr /I /C:"%%aVolume" "!_temp!\crvProductIds.txt" %_Nul1% && (
find /i "Office21%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0) || (set _%%a=1)
)
)
for %%a in (%_V19Ids%) do (
findstr /I /C:"%%aVolume" "!_temp!\crvProductIds.txt" %_Nul1% && (
find /i "Office19%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0) || (set _%%a=1)
@ -330,6 +459,10 @@ findstr /I /C:"%%aRetail" "!_temp!\crvProductIds.txt" %_Nul1% && (
find /i "Office19%%aR_OEM" "!_temp!\crvRetail.txt" %_Nul1% && set _%%a=0
find /i "Office19%%aMSDNR_" "!_temp!\crvRetail.txt" %_Nul1% && set _%%a=0
find /i "Office19%%aVL_MAK" "!_temp!\crvRetail.txt" %_Nul1% && set _%%a=0
find /i "Office21%%aR_Retail" "!_temp!\crvRetail.txt" %_Nul1% && set _%%a=0
find /i "Office21%%aR_OEM" "!_temp!\crvRetail.txt" %_Nul1% && set _%%a=0
find /i "Office21%%aMSDNR_" "!_temp!\crvRetail.txt" %_Nul1% && set _%%a=0
find /i "Office21%%aVL_MAK" "!_temp!\crvRetail.txt" %_Nul1% && set _%%a=0
)
)
if %_Retail% EQU 1 reg query %_PRIDs%\ProPlusRetail.16 %_Nul3% && (
@ -338,36 +471,50 @@ if %_Retail% EQU 1 reg query %_PRIDs%\ProPlusRetail.16 %_Nul3% && (
find /i "Office16ProPlusMSDNR_" "!_temp!\crvRetail.txt" %_Nul1% && set _ProPlus=0
find /i "Office16ProPlusVL_MAK" "!_temp!\crvRetail.txt" %_Nul1% && set _ProPlus=0
)
set "_qr=%_zz1% %_spp% %_zz2% "ApplicationID='%_oApp%' AND LicenseFamily like 'Office16O365%%'" %_zz3% LicenseFamily %_zz4%"
find /i "Office16MondoVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (
wmic path %spp% where 'ApplicationID="%_oApp%" AND LicenseFamily like "Office16O365%%"' get LicenseFamily %_Nul2% | find /i "O365" %_Nul1% && (
%_qr% %_Nul2% | find /i "O365" %_Nul1% && (
for %%a in (O365ProPlus,O365Business,O365SmallBusPrem,O365HomePrem,O365EduCloud) do set _%%a=0
)
)
if %sub_O365% EQU 1 (
for %%a in (%_Suites%) do set _%%a=0
echo Microsoft 365 product is activated with a subscription.
echo.
)
if %sub_proj% EQU 1 (
for %%a in (%_PrjSKU%) do set _%%a=0
echo Microsoft Project is activated with a subscription.
echo.
)
if %sub_vis% EQU 1 (
for %%a in (%_VisSKU%) do set _%%a=0
echo Microsoft Visio is activated with a subscription.
echo.
)
if %_Cnvrt% NEQ 1 (if %_Office15% EQU 1 (goto :R15V) else (set "msg=Finished"&goto :TheEnd))
set _C16Msg=0
for %%a in (%_RetIds%,ProPlus) do if !_%%a! EQU 1 (
set _C16Msg=1
)
if %_C16Msg% EQU 1 (
echo.
echo %_ln%
echo Installing Office Volume Licenses...
echo %_ln%
echo.
)
if %_C16Msg% EQU 0 (if %_Office15% EQU 1 (goto :R15V) else (goto :GVLKC2R))
if !_Mondo! EQU 1 (
call :InsLic Mondo
)
if !_O365ProPlus! EQU 1 (
if !_O365asO2019! EQU 1 (
if !_Mondo! EQU 0 (
echo O365ProPlus 2016 Suite -^> ProPlus%_ons% Licenses
echo.
call :InsLic ProPlus%_tag%
)
) else (
echo O365ProPlus 2016 Suite ^<-^> Mondo 2016 Licenses
echo.
call :InsLic O365ProPlus DRNV7-VGMM2-B3G9T-4BF84-VMFTK
if !_Mondo! EQU 0 call :InsLic Mondo
)
echo O365ProPlus 2016 Suite ^<-^> Mondo 2016 Licenses
echo.
call :InsLic O365ProPlus DRNV7-VGMM2-B3G9T-4BF84-VMFTK
if !_Mondo! EQU 0 call :InsLic Mondo
)
if !_O365Business! EQU 1 if !_O365ProPlus! EQU 0 (
set _O365ProPlus=1
@ -404,102 +551,153 @@ echo.
call :InsLic O365ProPlus DRNV7-VGMM2-B3G9T-4BF84-VMFTK
if %_Office15% EQU 1 (goto :R15V) else (goto :GVLKC2R)
)
if !_ProPlus2019! EQU 1 if !_O365ProPlus! EQU 0 (
echo ProPlus 2019 Suite
if !_ProPlus2021! EQU 1 if !_O365ProPlus! EQU 0 (
echo ProPlus 2021 Suite
echo.
call :InsLic ProPlus2021
)
if !_ProPlus2019! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 (
echo ProPlus 2019 Suite -^> ProPlus%_ons% Licenses
echo.
call :InsLic ProPlus%_tag%
)
if !_ProPlus! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 (
if !_ProPlus! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 (
echo ProPlus 2016 Suite -^> ProPlus%_ons% Licenses
echo.
call :InsLic ProPlus%_tag%
)
if !_Professional2019! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 (
if !_Professional2021! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 (
echo Professional 2021 Suite -^> ProPlus 2021 Licenses
echo.
call :InsLic ProPlus2021
)
if !_Professional2019! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 (
echo Professional 2019 Suite -^> ProPlus%_ons% Licenses
echo.
call :InsLic ProPlus%_tag%
)
if !_Professional! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2019! EQU 0 (
if !_Professional! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 (
echo Professional 2016 Suite -^> ProPlus%_ons% Licenses
echo.
call :InsLic ProPlus%_tag%
)
if !_Standard2019! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 (
echo Standard 2019 Suite
if !_Standard2021! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 (
echo Standard 2021 Suite
echo.
call :InsLic Standard2019
call :InsLic Standard2021
)
if !_Standard! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2019! EQU 0 (
if !_Standard2019! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2021! EQU 0 (
echo Standard 2019 Suite -^> Standard%_ons% Licenses
echo.
call :InsLic Standard%_tag%
)
if !_Standard! EQU 1 if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2021! EQU 0 if !_Standard2019! EQU 0 (
echo Standard 2016 Suite -^> Standard%_ons% Licenses
echo.
call :InsLic Standard%_tag%
)
for %%a in (ProjectPro,VisioPro,ProjectStd,VisioStd) do if !_%%a2021! EQU 1 (
echo %%a 2021 SKU
echo.
call :InsLic %%a2021
)
for %%a in (ProjectPro,VisioPro,ProjectStd,VisioStd) do if !_%%a2019! EQU 1 (
echo %%a 2019 SKU
echo.
if defined _tag (call :InsLic %%a2019) else (call :InsLic %%a)
if !_%%a2021! EQU 0 (
echo %%a 2019 SKU -^> %%a%_ons% Licenses
echo.
call :InsLic %%a%_tag%
)
)
for %%a in (ProjectPro,VisioPro,ProjectStd,VisioStd) do if !_%%a! EQU 1 (
if !_%%a2019! EQU 0 (
if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 (
echo %%a 2016 SKU -^> %%a%_ons% Licenses
echo.
call :InsLic %%a%_tag%
)
)
for %%a in (HomeBusiness2019,HomeStudent2019) do if !_%%a! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2019! EQU 0 if !_Standard! EQU 0 (
set _Standard2019=1
echo %%a Suite -^> Standard 2019 Licenses
for %%a in (HomeBusiness,HomeStudent) do if !_%%a2021! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2021! EQU 0 if !_Standard2019! EQU 0 if !_Standard! EQU 0 (
set _Standard2021=1
echo %%a 2021 Suite -^> Standard 2021 Licenses
echo.
call :InsLic Standard2019
call :InsLic Standard2021
)
)
for %%a in (HomeBusiness,HomeStudent) do if !_%%a2019! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2021! EQU 0 if !_Standard2019! EQU 0 if !_Standard! EQU 0 if !_%%a2021! EQU 0 (
set _Standard2019=1
echo %%a 2019 Suite -^> Standard%_ons% Licenses
echo.
call :InsLic Standard%_tag%
)
)
for %%a in (HomeBusiness,HomeStudent) do if !_%%a! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2019! EQU 0 if !_Standard! EQU 0 if !_%%a2019! EQU 0 (
set _Standard2019=1
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2021! EQU 0 if !_Standard2019! EQU 0 if !_Standard! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 (
set _Standard=1
echo %%a 2016 Suite -^> Standard%_ons% Licenses
echo.
call :InsLic Standard%_tag%
)
)
for %%a in (%_A19Ids%,OneNote) do if !_%%a! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2019! EQU 0 if !_Standard! EQU 0 (
for %%a in (%_A21Ids%,OneNote) do if !_%%a! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2021! EQU 0 if !_Standard2019! EQU 0 if !_Standard! EQU 0 (
echo %%a App
echo.
call :InsLic %%a
)
)
for %%a in (%_A16Ids%) do if !_%%a2019! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2021! EQU 0 if !_Standard2019! EQU 0 if !_Standard! EQU 0 if !_%%a2021! EQU 0 (
echo %%a 2019 App -^> %%a%_ons% Licenses
echo.
call :InsLic %%a%_tag%
)
)
for %%a in (%_A16Ids%) do if !_%%a! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2019! EQU 0 if !_Standard! EQU 0 if !_%%a2019! EQU 0 (
echo %%a 2016 App
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_Standard2021! EQU 0 if !_Standard2019! EQU 0 if !_Standard! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 (
echo %%a 2016 App -^> %%a%_ons% Licenses
echo.
call :InsLic %%a%_tag%
)
)
for %%a in (Access2019) do if !_%%a! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 (
echo %%a App
for %%a in (Access) do if !_%%a2021! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 (
echo %%a 2021 App
echo.
call :InsLic %%a
call :InsLic %%a2021
)
)
for %%a in (Access) do if !_%%a2019! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_%%a2021! EQU 0 (
echo %%a 2019 App -^> %%a%_ons% Licenses
echo.
call :InsLic %%a%_tag%
)
)
for %%a in (Access) do if !_%%a! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_%%a2019! EQU 0 (
echo %%a 2016 App
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_Professional2021! EQU 0 if !_Professional2019! EQU 0 if !_Professional! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 (
echo %%a 2016 App -^> %%a%_ons% Licenses
echo.
call :InsLic %%a%_tag%
)
)
for %%a in (SkypeforBusiness2019) do if !_%%a! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 (
echo %%a App
for %%a in (SkypeforBusiness) do if !_%%a2021! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 (
echo %%a 2021 App
echo.
call :InsLic %%a
call :InsLic %%a2021
)
)
for %%a in (SkypeforBusiness) do if !_%%a2019! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_%%a2021! EQU 0 (
echo %%a 2019 App -^> %%a%_ons% Licenses
echo.
call :InsLic %%a%_tag%
)
)
for %%a in (SkypeforBusiness) do if !_%%a! EQU 1 (
if !_O365ProPlus! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_%%a2019! EQU 0 (
echo %%a 2016 App
if !_O365ProPlus! EQU 0 if !_ProPlus2021! EQU 0 if !_ProPlus2019! EQU 0 if !_ProPlus! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 (
echo %%a 2016 App -^> %%a%_ons% Licenses
echo.
call :InsLic %%a%_tag%
)
@ -555,18 +753,25 @@ if %_Retail% EQU 1 reg query %_PR15IDs%\Active\ProPlusRetail\x-none %_Nul3% && (
find /i "OfficeProPlusMSDNR_" "!_temp!\crvRetail.txt" %_Nul1% && set _ProPlus=0
find /i "OfficeProPlusVL_MAK" "!_temp!\crvRetail.txt" %_Nul1% && set _ProPlus=0
)
set "_qr=%_zz1% %_spp% %_zz2% "ApplicationID='%_oApp%' AND LicenseFamily like 'OfficeO365%%'" %_zz3% LicenseFamily %_zz4%"
find /i "OfficeMondoVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (
wmic path %spp% where 'ApplicationID="%_oApp%" AND LicenseFamily like "OfficeO365%%"' get LicenseFamily %_Nul2% | find /i "O365" %_Nul1% && (
%_qr% %_Nul2% | find /i "O365" %_Nul1% && (
for %%a in (O365ProPlus,O365Business,O365SmallBusPrem,O365HomePrem) do set _%%a=0
)
)
if %_Cnvrt% NEQ 1 (set "msg=Finished"&goto :TheEnd)
set _C15Msg=0
for %%a in (%_R15Ids%,ProPlus) do if !_%%a! EQU 1 (
set _C15Msg=1
)
if %_C15Msg% EQU 1 if %_C16Msg% EQU 0 (
echo.
echo %_ln%
echo Installing Office Volume Licenses...
echo %_ln%
echo.
)
if %_C15Msg% EQU 0 goto :GVLKC2R
if !_Mondo! EQU 1 (
@ -691,24 +896,41 @@ reg delete %_OSPP15Ready% /f /v %_ID%.OSPPReady %_Nul3%
for %%# in ("!_Licenses15Path!\%_patt%*.xrm-ms") do (
%_cscript% %_vbsi%"!_Licenses15Path!\%%~nx#"
)
if defined _pkey wmic path %_sps% where version='%_wmi%' call InstallProductKey ProductKey="%_pkey%" %_Nul3%
set "_qr=wmic path %_sps% where Version='%_wmi%' call InstallProductKey ProductKey="%_pkey%""
if %WMI_VBS% NEQ 0 set "_qr=%_csp% %_sps% "%_pkey%""
if defined _pkey %_qr% %_Nul3%
reg add %_OSPP15Ready% /f /v %_ID%.OSPPReady /t %_OSPP15ReadT% /d 1 %_Nul1%
reg query %_Con15fig% | findstr /I "%_ID%" %_Nul1%
reg query %_Con15fig% %_Nul2% | findstr /I "%_ID%" %_Nul1%
if %errorlevel% NEQ 0 (
for /f "skip=2 tokens=2*" %%a in ('reg query %_Con15fig%') do reg add %_Con15fig% /t REG_SZ /d "%%b,%_ID%" /f %_Nul1%
for /f "skip=2 tokens=2*" %%a in ('reg query %_Con15fig% %_Nul6%') do reg add %_Con15fig% /t REG_SZ /d "%%b,%_ID%" /f %_Nul1%
)
exit /b
:GVLKC2R
set _CtRMsg=0
if %_C16Msg% EQU 1 set _CtRMsg=1
if %_C15Msg% EQU 1 set _CtRMsg=1
if %_CtRMsg% EQU 1 (
echo %_ln%
echo Installing Missing KMS Client Keys...
echo %_ln%
echo.
if %winbuild% GEQ 9200 wmic path %_sps% where version='%_wmi%' call RefreshLicenseStatus %_Nul3%
for %%# in (15,16,19) do call :C2RLoc %%#
for %%# in (15,16,19) do if !_Office%%#! EQU 0 call :C2Runi %%#
for %%# in (15,16,19) do if !_Office%%#! EQU 1 call :C2Rins %%#
if %winbuild% GEQ 9200 wmic path %_sps% where version='%_wmi%' call RefreshLicenseStatus %_Nul3%
)
set "_qr=wmic path %_sps% where Version='%_wmi%' call RefreshLicenseStatus"
if %WMI_VBS% NEQ 0 set "_qr=%_csm% "%_sps%.Version='%_wmi%'" RefreshLicenseStatus"
if %winbuild% GEQ 9200 %_qr% %_Nul3%
for %%# in (15,16,19,21) do call :C2RLoc %%#
if %_Retail% EQU 0 if !_Loc15! EQU 0 call :C2Runi %%#
if %_Retail% EQU 0 if %sub_O365% EQU 0 if %sub_proj% EQU 0 if %sub_vis% EQU 0 (
if !_Loc16! EQU 0 call :C2Runi %%#
if !_Loc19! EQU 0 call :C2Runi %%#
if !_Loc21! EQU 0 call :C2Runi %%#
)
if %_C16Msg% EQU 1 for %%# in (16,19,21) do if !_Loc%%#! EQU 1 call :C2Rins %%#
if %_C15Msg% EQU 1 for %%# in (15) do if !_Loc%%#! EQU 1 call :C2Rins %%#
set "_qr=wmic path %_sps% where Version='%_wmi%' call RefreshLicenseStatus"
if %WMI_VBS% NEQ 0 set "_qr=%_csm% "%_sps%.Version='%_wmi%'" RefreshLicenseStatus"
if %winbuild% GEQ 9200 %_qr% %_Nul3%
if exist "%SysPath%\spp\store_test\2.0\tokens.dat" (
echo.
echo %_ln%
@ -721,61 +943,75 @@ set "msg=Finished"
goto :TheEnd
:C2Runi
for /f "tokens=2 delims==" %%# in ('wmic path %_spp% where "Name like 'Office %~1%%' AND PartialProductKey<>NULL" get ID /value %_Nul6%') do (set "aID=%%#"&call :UniKey)
set "_qr=%_zz1% %_spp% %_zz2% "Name like 'Office %~1%%' AND PartialProductKey is not NULL" %_zz3% ID %_zz4%"
for /f "tokens=2 delims==" %%# in ('%_qr% %_Nul6%') do (set "aID=%%#"&call :UniKey)
exit /b
:C2Rins
for /f "tokens=2 delims==" %%# in ('"wmic path %_spp% where (Description like 'Office %1, VOLUME_KMSCLIENT%%' AND PartialProductKey=NULL) get ID /value" %_Nul6%') do (set "aID=%%#"&call :InsKey)
set "_qr=%_zz7% %_spp% %_zz2% %_zz5%Description like 'Office %1, VOLUME_KMSCLIENT%%' AND PartialProductKey is NULL%_zz6% %_zz3% ID %_zz8%"
for /f "tokens=2 delims==" %%# in ('%_qr% %_Nul6%') do (set "aID=%%#"&call :InsKey)
exit /b
:C2RLoc
set _Office%1=0
set _Loc%1=0
if %1 EQU 19 (
if defined _ProductIds reg query %_Config% /v ProductReleaseIds %_Nul2% | findstr 2019 %_Nul1% && set _Office%1=1
if defined _ProductIds reg query %_Config% /v ProductReleaseIds %_Nul2% | findstr 2019 %_Nul1% && set _Loc%1=1
exit /b
)
if %1 EQU 21 (
if defined _ProductIds reg query %_Config% /v ProductReleaseIds %_Nul2% | findstr 2021 %_Nul1% && set _Loc%1=1
exit /b
)
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\%1.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\OSPP.VBS" set _Office%1=1
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\%1.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\OSPP.VBS" set _Office%1=1
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\%1.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\OSPP.VBS" set _Loc%1=1
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\%1.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\OSPP.VBS" set _Loc%1=1
if %1 EQU 16 if defined _ProductIds (
for /f "skip=2 tokens=2*" %%a in ('reg query %_Config% /v ProductReleaseIds') do echo %%b>"!_temp!\crvO16.txt"
for %%a in (%_R16Ids%) do (
findstr /I /C:"%%aRetail" "!_temp!\crvO16.txt" %_Nul1% && set _Office%1=1
findstr /I /C:"%%aRetail" "!_temp!\crvO16.txt" %_Nul1% && set _Loc%1=1
)
for %%a in (%_V16Ids%,ProjectProX,ProjectStdX,VisioProX,VisioStdX) do (
findstr /I /C:"%%aVolume" "!_temp!\crvO16.txt" %_Nul1% && set _Office%1=1
findstr /I /C:"%%aVolume" "!_temp!\crvO16.txt" %_Nul1% && set _Loc%1=1
)
reg query %_PRIDs%\ProPlusRetail.16 %_Nul3% && set _Office%1=1
reg query %_PRIDs%\ProPlusVolume.16 %_Nul3% && set _Office%1=1
reg query %_PRIDs%\ProPlusRetail.16 %_Nul3% && set _Loc%1=1
reg query %_PRIDs%\ProPlusVolume.16 %_Nul3% && set _Loc%1=1
exit /b
)
if %1 EQU 15 if defined _Product15Ids (
set _Office%1=1
set _Loc%1=1
exit /b
)
if exist "%ProgramFiles%\Microsoft Office\Office%1\OSPP.VBS" set _Office%1=1
if exist "%ProgramW6432%\Microsoft Office\Office%1\OSPP.VBS" set _Office%1=1
if exist "%ProgramFiles(x86)%\Microsoft Office\Office%1\OSPP.VBS" set _Office%1=1
if exist "%ProgramFiles%\Microsoft Office\Office%1\OSPP.VBS" set _Loc%1=1
if exist "%ProgramW6432%\Microsoft Office\Office%1\OSPP.VBS" set _Loc%1=1
if exist "%ProgramFiles(x86)%\Microsoft Office\Office%1\OSPP.VBS" set _Loc%1=1
exit /b
:UniKey
wmic path %_spp% where ID='%aID%' call UninstallProductKey %_Nul3%
set "_qr=wmic path %_spp% where ID='%aID%' call UninstallProductKey"
if %WMI_VBS% NEQ 0 set "_qr=%_csm% "%_spp%.ID='%aID%'" UninstallProductKey"
%_qr% %_Nul3%
exit /b
:InsKey
if /i '%aID%' EQU 'f3fb2d68-83dd-4c8b-8f09-08e0d950ac3b' exit /b
if /i '%aID%' EQU '76093b1b-7057-49d7-b970-638ebcbfd873' exit /b
if /i '%aID%' EQU 'a3b44174-2451-4cd6-b25f-66638bfb9046' exit /b
if /i '%aID%' EQU '1dc00701-03af-4680-b2af-007ffc758a1f' exit /b
if /i '%aID%' EQU 'e914ea6e-a5fa-4439-a394-a9bb3293ca09' exit /b
if /i '%aID%' EQU '0bc88885-718c-491d-921f-6f214349e79c' exit /b
if /i '%aID%' EQU 'fc7c4d0c-2e85-4bb9-afd4-01ed1476b5e9' exit /b
if /i '%aID%' EQU '500f6619-ef93-4b75-bcb4-82819998a3ca' exit /b
if /i '%aID%' EQU 'e914ea6e-a5fa-4439-a394-a9bb3293ca09' exit /b
set "_key="
for /f "tokens=2 delims==" %%# in ('"wmic path %_spp% where ID='%aID%' get LicenseFamily /value"') do echo %%#
set "_qr=%_zz7% %_spp% %_zz2% %_zz5%ID='%aID%'%_zz6% %_zz3% LicenseFamily %_zz8%"
for /f "tokens=2 delims==" %%# in ('%_qr%') do echo %%#
call :keys %aID%
if "%_key%"=="" (echo Could not find matching key&echo.&exit /b)
wmic path %_sps% where version='%_wmi%' call InstallProductKey ProductKey="%_key%" %_Nul3%
if "%_key%"=="" (echo No associated KMS Client key found&echo.&exit /b)
set "_qr=wmic path %_sps% where Version='%_wmi%' call InstallProductKey ProductKey="%_key%""
if %WMI_VBS% NEQ 0 set "_qr=%_csp% %_sps% "%_pkey%""
%_qr% %_Nul3%
set ERRORCODE=%ERRORLEVEL%
if %ERRORCODE% NEQ 0 (
cmd /c exit /b %ERRORCODE%
@ -788,6 +1024,59 @@ exit /b
if "%~1"=="" exit /b
goto :%1 %_Nul2%
:: Office 2021
:fbdb3e18-a8ef-4fb3-9183-dffd60bd0984
set "_key=FXYTK-NJJ8C-GB6DW-3DYQT-6F7TH" &:: Professional Plus
exit /b
:080a45c5-9f9f-49eb-b4b0-c3c610a5ebd3
set "_key=KDX7X-BNVR8-TXXGX-4Q7Y8-78VT3" &:: Standard
exit /b
:76881159-155c-43e0-9db7-2d70a9a3a4ca
set "_key=FTNWT-C6WBT-8HMGF-K9PRX-QV9H8" &:: Project Professional
exit /b
:6dd72704-f752-4b71-94c7-11cec6bfc355
set "_key=J2JDC-NJCYY-9RGQ4-YXWMH-T3D4T" &:: Project Standard
exit /b
:fb61ac9a-1688-45d2-8f6b-0674dbffa33c
set "_key=KNH8D-FGHT4-T8RK3-CTDYJ-K2HT4" &:: Visio Professional
exit /b
:72fce797-1884-48dd-a860-b2f6a5efd3ca
set "_key=MJVNY-BYWPY-CWV6J-2RKRT-4M8QG" &:: Visio Standard
exit /b
:1fe429d8-3fa7-4a39-b6f0-03dded42fe14
set "_key=WM8YG-YNGDD-4JHDC-PG3F4-FC4T4" &:: Access
exit /b
:ea71effc-69f1-4925-9991-2f5e319bbc24
set "_key=NWG3X-87C9K-TC7YY-BC2G7-G6RVC" &:: Excel
exit /b
:a5799e4c-f83c-4c6e-9516-dfe9b696150b
set "_key=C9FM6-3N72F-HFJXB-TM3V9-T86R9" &:: Outlook
exit /b
:6e166cc3-495d-438a-89e7-d7c9e6fd4dea
set "_key=TY7XF-NFRBR-KJ44C-G83KF-GX27K" &:: PowerPoint
exit /b
:aa66521f-2370-4ad8-a2bb-c095e3e4338f
set "_key=2MW9D-N4BXM-9VBPG-Q7W6M-KFBGQ" &:: Publisher
exit /b
:1f32a9af-1274-48bd-ba1e-1ab7508a23e8
set "_key=HWCXN-K3WBT-WJBKY-R8BD9-XK29P" &:: Skype for Business
exit /b
:abe28aea-625a-43b1-8e30-225eb8fbd9e5
set "_key=TN8H9-M34D3-Y64V9-TR72V-X79KV" &:: Word
exit /b
:: Office 2019
:85dd8b5f-eaa4-4af3-a628-cce9e77c9a03
set "_key=NMMKJ-6RK4F-KMJVX-8D9MJ-6MWKP" &:: Professional Plus
@ -991,6 +1280,16 @@ exit /b
set "_key=6Q7VD-NX8JD-WJ2VH-88V73-4GBJ7" &:: Word
exit /b
:E_VBS
echo %_err%
echo Windows Script Host is disabled.
echo It is required for this script to work.
echo.
echo Press any key to exit.
if %_Debug% EQU 1 goto :eof
pause >nul
goto :eof
:TheEnd
if exist "%_temp%\crv*.txt" del /f /q "%_temp%\crv*.txt"
echo.
@ -1002,3 +1301,51 @@ echo Press any key to exit...
if %_Debug% EQU 1 goto :eof
pause >nul
goto :eof
----- Begin wsf script --->
<package>
<job id="WmiQuery">
<script language="VBScript">
If WScript.Arguments.Count = 3 Then
wExc = "Select " & WScript.Arguments.Item(2) & " from " & WScript.Arguments.Item(0) & " where " & WScript.Arguments.Item(1)
wGet = WScript.Arguments.Item(2)
Else
wExc = "Select " & WScript.Arguments.Item(1) & " from " & WScript.Arguments.Item(0)
wGet = WScript.Arguments.Item(1)
End If
Set objCol = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery(wExc,,48)
For Each objItm in objCol
For each Prop in objItm.Properties_
If LCase(Prop.Name) = LCase(wGet) Then
WScript.Echo Prop.Name & "=" & Prop.Value
Exit For
End If
Next
Next
</script>
</job>
<job id="WmiMethod">
<script language="VBScript">
On Error Resume Next
wPath = WScript.Arguments.Item(0)
wMethod = WScript.Arguments.Item(1)
Set objCol = GetObject("winmgmts:\\.\root\CIMV2:" & wPath)
objCol.ExecMethod_(wMethod)
WScript.Quit Err.Number
</script>
</job>
<job id="WmiPKey">
<script language="VBScript">
On Error Resume Next
wExc = "SELECT Version FROM " & WScript.Arguments.Item(0)
wKey = WScript.Arguments.Item(1)
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery(wExc,,48)
For each colService in objWMIService
Exit For
Next
set objService = colService
objService.InstallProductKey(wKey)
WScript.Quit Err.Number
</script>
</job>
</package>

View file

@ -1,64 +1,74 @@
# Office Click-to-Run Retail-to-Volume
* Convert already-installed Office ClickToRun licensing from Retail to Volume
- Convert already-installed Office ClickToRun licensing from Retail to Volume
- This is not an activator, just a licensing converter
* Supports: Office 365, Office 2019, Office 2016, Office 2013
- Supports: Office 365, Office 2021, Office 2019, Office 2016, Office 2013
- Activated Retail products will be skipped from conversion
this include valid Office 365 subscriptions, or perpetual Office (MAK, OEM, MSDN, Retail..)
* Current Office licenses will be cleaned up (unless retail-activated Office detected)
- Current Office licenses will be cleaned up (unless retail-activated Office detected)
then, proper Volume licenses will be installed based on the detected Product IDs
- Office Mondo suite cover all products, if detected, only its licenses will be installed
* Office 365 products will be converted with Mondo licenses by default
- Microsoft Office 365 products will be converted with Mondo licenses by default
also, corresponding Office 365 Retail Grace Key will be installed
- Office 2016 products will be converted with corresponding Office 2019 licenses
- Windows 10/11: Office 2016 products will be converted with corresponding Office 2019 licenses (if RTM detected)
* Office Professional suite will be converted with Office 2019 ProPlus licenses
- Windows 8.1: Office 2016/2019 products will be converted with corresponding Office 2021 licenses (if RTM detected)
- Office HomeBusiness/HomeStudent suites will be converted with Office 2019 Standard licenses
- Office Professional suite will be converted with Office Professional Plus licenses
* If Office 2019 RTM licenses are not detected, Office 2016 licenses will be used instead
- Office HomeBusiness/HomeStudent suites will be converted with Office Standard licenses
- Office 2013 products follow the same logic, but handled separately
* If main products SKUs are detected, single apps licenses will not be installed to avoid duplication
- If main products Suites are detected, single apps licenses will not be installed to avoid duplication
- SKUs:
- Suites:
O365ProPlus, O365Business, O365SmallBusPrem, O365HomePrem, O365EduCloud
ProPlus, Professional, Standard, HomeBusiness, HomeStudent, Visio, Project
* Apps:
- Apps:
Access, Excel, InfoPath, Onenote, Outlook, PowerPoint, Publisher, SkypeForBusiness, Word, Groove (OneDrive for Business)
- O365ProPlus, O365Business, O365SmallBusPrem, ProPlus cover all apps
Professional cover all apps except SkypeForBusiness
Standard cover all apps except Access, SkypeForBusiness
- Suites <> Apps relation:
O365ProPlus, O365Business, O365SmallBusPrem, ProPlus: all apps
O365HomePrem, Professional: all apps except SkypeForBusiness
Standard: all apps except Access, SkypeForBusiness
HomeBusiness: Excel, OneNote, PowerPoint, Word, Outlook
HomeStudent: Excel, OneNote, PowerPoint, Word
## Notice
## Remarks
* On Windows 7, Office 2016/2019 licensing service require Universal C Runtime to work correctly
- wmic.exe tool is removed from Windows 11 build 22483 and later
In order to overcome this, the converter incorporate simple VBScripts to query and execute WMI functions
This require Windows Script Host to be working and not disabled
- On Windows 7, Office C2R 16.0 licensing service require Universal C Runtime to work correctly
- UCRT is available in the latest Monthly Rollup, or the separate update KB3118401
* Additionally, Office programs themselves require recent Windows 7 updates to start properly
- Additionally, Office programs themselves require recent Windows 7 updates to start properly
## Office 2019
- While Office 2021 can be installed on Windows 7, it will not function or work properly
* Office 2019 products are officially blocked on Windows 7 and 8.1
to workaround that, follow these steps:
## Office 2019/2021
- If you want Office Professional Plus 2019:
1) install O365ProPlusRetail SKU, then edit C2R-R2V.cmd and set _O365asO2019=1
2) alternatively, install Office 16 ProPlusRetail SKU (no need to edit the script in this case)
3) run C2R-R2V.cmd
- Office 2019/2021 products are officially blocked on Windows 7 and 8.1
to workaround that, use the following steps
* Additionally, if you want Project 2019 and/or Visio 2019:
- If you want Office Professional Plus:
1) install Office 2016 SKU ProPlusRetail
2) run C2R-R2V.cmd
- Additionally, if you want Project and/or Visio:
1) install desired Office 2016 SKU: ProjectProRetail, ProjectStdRetail, VisioProRetail, VisioStdRetail
2) run C2R-R2V.cmd
@ -67,11 +77,11 @@ to workaround that, follow these steps:
- To run the process in debug mode "with" conversion
edit C2R-R2V.cmd and set _Debug=1
* To run the process in debug mode "without" conversion
- To run the process in debug mode "without" conversion
edit C2R-R2V.cmd and set _Cnvrt=0
## Credits
- @abbodi1406 / Author
* @Windows_Addict / Features suggestion, testing and co-enhancing
- @Windows_Addict / Features suggestion, testing and co-enhancing
- @ratzlefatz / [OfficeRTool](https://forums.mydigitallife.net/posts/1125229/)

View file

@ -1,3 +1,4 @@
<!-- : Begin batch script
@setlocal DisableDelayedExpansion
@echo off
set "_cmdf=%~f0"
@ -23,6 +24,15 @@ if %winbuild% LSS 7601 (
set "msg=ERROR: Windows 7 SP1 is the minimum supported OS"
goto :end
)
set "_csq=cscript.exe //NoLogo //Job:WmiQuery "%~nx0?.wsf""
set "_csm=cscript.exe //NoLogo //Job:WmiMethod "%~nx0?.wsf""
set WMI_VBS=0
if %winbuild% GEQ 22483 set WMI_VBS=1
set _WSH=1
reg query "HKCU\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0)
reg query "HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0)
set "_oApp=0ff1ce15-a989-479d-af46-f275c6370663"
set "_oA14=59a52881-a989-479d-af46-f275c6370663"
set "_Common=%CommonProgramFiles%"
if defined PROCESSOR_ARCHITEW6432 set "_Common=%CommonProgramW6432%"
if /i "%PROCESSOR_ARCHITECTURE%"=="amd64" set "xBit=x64"
@ -102,7 +112,8 @@ echo.
echo ============================================================
echo Uninstalling Product Key^(s)
echo ============================================================
call :cKMS
call :cKMS %_Nul3%
if %WMI_VBS% NEQ 0 cd bin
:proceed
if exist "!_file!" (
@ -174,27 +185,35 @@ set "msg=Finished. It's recommended to restart the system."
goto :end
:cKMS
set "OSPP=SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform"
set "OPPk=SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform"
set "SPPk=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
if %winbuild% geq 9200 (
set spp=SoftwareLicensingProduct
reg delete "HKLM\%SPPk%\0ff1ce15-a989-479d-af46-f275c6370663" /f
reg delete "HKEY_USERS\S-1-5-20\%SPPk%\0ff1ce15-a989-479d-af46-f275c6370663" /f
) else (
set spp=OfficeSoftwareProtectionProduct
reg delete "HKLM\%OPPk%\0ff1ce15-a989-479d-af46-f275c6370663" /f
reg delete "HKEY_USERS\S-1-5-20\%OPPk%" /f
)
for /f "tokens=2 delims==" %%G in ('"wmic path %spp% where (Name LIKE 'Office%%' AND PartialProductKey is not NULL) get ID /VALUE" %_Nul6%') do (set app=%%G&call :Clear)
if %winbuild% geq 9200 (
reg delete "HKLM\%SPPk%\0ff1ce15-a989-479d-af46-f275c6370663" /f %_Nul3%
reg delete "HKEY_USERS\S-1-5-20\%SPPk%\0ff1ce15-a989-479d-af46-f275c6370663" /f %_Nul3%
) else (
reg delete "HKLM\%OSPP%\0ff1ce15-a989-479d-af46-f275c6370663" /f %_Nul3%
reg delete "HKEY_USERS\S-1-5-20\%OSPP%" /f %_Nul3%
)
if %_WSH% EQU 0 if %WMI_VBS% NEQ 0 goto :eof
if %WMI_VBS% NEQ 0 cd ..
set "_ocq=Name LIKE 'Office%%' AND PartialProductKey is not NULL"
set "_qr="wmic path %spp% where (%_ocq%) get ID /VALUE""
if %WMI_VBS% NEQ 0 set "_qr=%_csq% %spp% "%_ocq%" ID"
for /f "tokens=2 delims==" %%G in ('%_qr% %_Nul6%') do (set app=%%G&call :cAPP %_Nul3%)
goto :eof
:Clear
wmic path %spp% where ID='%app%' call ClearKeyManagementServiceMachine %_Nul3%
wmic path %spp% where ID='%app%' call ClearKeyManagementServicePort %_Nul3%
wmic path %spp% where ID='%app%' call UninstallProductKey %_Nul3%
:cAPP
if %winbuild% geq 9200 (
reg delete "HKLM\%SPPk%\%_oApp%\%app%" /f %_Null%
) else (
reg delete "HKLM\%OPPk%\%_oA14%\%app%" /f %_Null%
reg delete "HKLM\%OPPk%\%_oApp%\%app%" /f %_Null%
)
set "_qr=wmic path %spp% where ID='%app%' call UninstallProductKey"
if %WMI_VBS% NEQ 0 set "_qr=%_csm% "%spp%.ID='%app%'" UninstallProductKey"
%_qr%
goto :eof
:end
@ -205,4 +224,38 @@ echo ============================================================
echo.
echo Press any key to exit.
pause >nul
goto :eof
goto :eof
----- Begin wsf script --->
<package>
<job id="WmiQuery">
<script language="VBScript">
If WScript.Arguments.Count = 3 Then
wExc = "Select " & WScript.Arguments.Item(2) & " from " & WScript.Arguments.Item(0) & " where " & WScript.Arguments.Item(1)
wGet = WScript.Arguments.Item(2)
Else
wExc = "Select " & WScript.Arguments.Item(1) & " from " & WScript.Arguments.Item(0)
wGet = WScript.Arguments.Item(1)
End If
Set objCol = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery(wExc,,48)
For Each objItm in objCol
For each Prop in objItm.Properties_
If LCase(Prop.Name) = LCase(wGet) Then
WScript.Echo Prop.Name & "=" & Prop.Value
Exit For
End If
Next
Next
</script>
</job>
<job id="WmiMethod">
<script language="VBScript">
On Error Resume Next
wPath = WScript.Arguments.Item(0)
wMethod = WScript.Arguments.Item(1)
Set objCol = GetObject("winmgmts:\\.\root\CIMV2:" & wPath)
objCol.ExecMethod_(wMethod)
WScript.Quit Err.Number
</script>
</job>
</package>

View file

@ -1,3 +1,4 @@
<!-- : Begin batch script
@setlocal DisableDelayedExpansion
@echo off
set "_cmdf=%~f0"
@ -23,6 +24,15 @@ if %winbuild% LSS 7601 (
set "msg=ERROR: Windows 7 SP1 is the minimum supported OS"
goto :end
)
set "_csq=cscript.exe //NoLogo //Job:WmiQuery "%~nx0?.wsf""
set "_csm=cscript.exe //NoLogo //Job:WmiMethod "%~nx0?.wsf""
set WMI_VBS=0
if %winbuild% GEQ 22483 set WMI_VBS=1
set _WSH=1
reg query "HKCU\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0)
reg query "HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0)
set "_oApp=0ff1ce15-a989-479d-af46-f275c6370663"
set "_oA14=59a52881-a989-479d-af46-f275c6370663"
set "_Common=%CommonProgramFiles%"
if defined PROCESSOR_ARCHITEW6432 set "_Common=%CommonProgramW6432%"
if /i "%PROCESSOR_ARCHITECTURE%"=="amd64" set "xBit=x64"
@ -96,6 +106,7 @@ echo ============================================================
echo.
%xBit%\cleanospp.exe -PKey %_Nul3%
call :cKMS %_Nul3%
if %WMI_VBS% NEQ 0 cd bin
if exist "%SysPath%\spp\store_test\2.0\tokens.dat" (
echo.
echo ============================================================
@ -108,27 +119,35 @@ set "msg=Finished."
goto :end
:cKMS
set "OSPP=SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform"
set "OPPk=SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform"
set "SPPk=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
if %winbuild% geq 9200 (
set spp=SoftwareLicensingProduct
reg delete "HKLM\%SPPk%\0ff1ce15-a989-479d-af46-f275c6370663" /f
reg delete "HKEY_USERS\S-1-5-20\%SPPk%\0ff1ce15-a989-479d-af46-f275c6370663" /f
) else (
set spp=OfficeSoftwareProtectionProduct
reg delete "HKLM\%OPPk%\0ff1ce15-a989-479d-af46-f275c6370663" /f
reg delete "HKEY_USERS\S-1-5-20\%OPPk%" /f
)
for /f "tokens=2 delims==" %%G in ('"wmic path %spp% where (Name LIKE 'Office%%' AND PartialProductKey is not NULL) get ID /VALUE" %_Nul6%') do (set app=%%G&call :cAPP %_Nul3%)
call :cREG %_Nul3%
if %_WSH% EQU 0 if %WMI_VBS% NEQ 0 goto :eof
if %WMI_VBS% NEQ 0 cd ..
set "_ocq=Name LIKE 'Office%%' AND PartialProductKey is not NULL"
set "_qr="wmic path %spp% where (%_ocq%) get ID /VALUE""
if %WMI_VBS% NEQ 0 set "_qr=%_csq% %spp% "%_ocq%" ID"
for /f "tokens=2 delims==" %%G in ('%_qr% %_Nul6%') do (set app=%%G&call :cAPP %_Nul3%)
goto :eof
:cAPP
wmic path %spp% where ID='%app%' call ClearKeyManagementServiceMachine
wmic path %spp% where ID='%app%' call ClearKeyManagementServicePort
wmic path %spp% where ID='%app%' call UninstallProductKey
goto :eof
:cREG
reg delete "HKLM\%OSPP%\0ff1ce15-a989-479d-af46-f275c6370663" /f
reg delete "HKLM\%SPPk%\0ff1ce15-a989-479d-af46-f275c6370663" /f
reg delete "HKU\S-1-5-20\%SPPk%\0ff1ce15-a989-479d-af46-f275c6370663" /f
if %winbuild% geq 9200 (
reg delete "HKLM\%SPPk%\%_oApp%\%app%" /f %_Null%
) else (
reg delete "HKLM\%OPPk%\%_oA14%\%app%" /f %_Null%
reg delete "HKLM\%OPPk%\%_oApp%\%app%" /f %_Null%
)
set "_qr=wmic path %spp% where ID='%app%' call UninstallProductKey"
if %WMI_VBS% NEQ 0 set "_qr=%_csm% "%spp%.ID='%app%'" UninstallProductKey"
%_qr%
goto :eof
:end
@ -139,4 +158,38 @@ echo ============================================================
echo.
echo Press any key to exit.
pause >nul
goto :eof
goto :eof
----- Begin wsf script --->
<package>
<job id="WmiQuery">
<script language="VBScript">
If WScript.Arguments.Count = 3 Then
wExc = "Select " & WScript.Arguments.Item(2) & " from " & WScript.Arguments.Item(0) & " where " & WScript.Arguments.Item(1)
wGet = WScript.Arguments.Item(2)
Else
wExc = "Select " & WScript.Arguments.Item(1) & " from " & WScript.Arguments.Item(0)
wGet = WScript.Arguments.Item(1)
End If
Set objCol = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery(wExc,,48)
For Each objItm in objCol
For each Prop in objItm.Properties_
If LCase(Prop.Name) = LCase(wGet) Then
WScript.Echo Prop.Name & "=" & Prop.Value
Exit For
End If
Next
Next
</script>
</job>
<job id="WmiMethod">
<script language="VBScript">
On Error Resume Next
wPath = WScript.Arguments.Item(0)
wMethod = WScript.Arguments.Item(1)
Set objCol = GetObject("winmgmts:\\.\root\CIMV2:" & wPath)
objCol.ExecMethod_(wMethod)
WScript.Quit Err.Number
</script>
</job>
</package>