Browse Source

20221026

pull/19/head
abbodi1406 3 years ago
parent
commit
c9ba8d6f4e
  1. 113
      OfficeC2R-R2V/C2R-R2V.cmd
  2. 81
      OfficeScrubber/Clean_Subscription_Licenses.cmd
  3. 276
      OfficeScrubber/Full_Scrub.cmd
  4. 633
      OfficeScrubber/OfficeScrubber.cmd
  5. 86
      OfficeScrubber/README.md
  6. 126
      OfficeScrubber/Remove_Licenses.cmd
  7. 130
      OfficeScrubber/Reset_Licenses.cmd
  8. 208
      OfficeScrubber/Uninstall_Keys.cmd
  9. 697
      OfficeScrubber/bin/OLicenseCleanup.vbs
  10. BIN
      OfficeScrubber/bin/OffScrub03.vbs
  11. BIN
      OfficeScrubber/bin/OffScrub07.vbs
  12. BIN
      OfficeScrubber/bin/OffScrub10.vbs
  13. BIN
      OfficeScrubber/bin/OffScrubC2R.vbs
  14. BIN
      OfficeScrubber/bin/OffScrub_O15msi.vbs
  15. BIN
      OfficeScrubber/bin/OffScrub_O16msi.vbs
  16. 27
      OfficeScrubber/bin/WAMAccounts.ps1
  17. 62
      W10MUI/Updates/W10UI.cmd
  18. 7
      W10UI/README.md
  19. 62
      W10UI/W10UI.cmd
  20. 2
      esd-decrypter-wimlib/decrypt.cmd

113
OfficeC2R-R2V/C2R-R2V.cmd

@ -1,12 +1,15 @@ @@ -1,12 +1,15 @@
<!-- : Begin batch script
@setlocal DisableDelayedExpansion
@set uivr=v16
@set uivr=v17
@echo off
:: set to 1 to enable debug mode
:: change to 0 to keep Office C2R vNext license (subscription or lifetime)
set vNextOverride=1
:: change to 1 to enable debug mode
set _Debug=0
:: set to 0 to enable debug mode without cleaning or converting
:: change to 0 to enable debug mode without cleaning or converting
set _Cnvrt=1
:: change to 1 to use VBScript to access WMI
@ -312,21 +315,21 @@ echo. @@ -312,21 +315,21 @@ echo.
echo %_ln%
echo Checking Office Licenses...
echo %_ln%
set "_qr=%_zz1% %_spp% %_zz2% %_zz5%ApplicationID='%_oApp%' AND Description like '%%KMSCLIENT%%' %_zz6% %_zz3% LicenseFamily %_zz4%"
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%"
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%"
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%"
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%"
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)
)
set "_qr=%_zz1% %_spp% %_zz2% "ApplicationID='%_oApp%' AND LicenseFamily like 'OfficeO365%%'" %_zz3% LicenseFamily %_zz4%"
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)
)
@ -335,24 +338,32 @@ set "msg=No Conversion or Cleanup Required..." @@ -335,24 +338,32 @@ set "msg=No Conversion or Cleanup Required..."
goto :TheEnd
)
set _Identity=0
set _vNext=0
set sub_O365=0
set sub_next=0
set sub_o365=0
set sub_proj=0
set sub_vis=0
set sub_vsio=0
set _Identity=0
set kNext=HKCU\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext
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)
if %_Identity% EQU 1 reg query %kNext% /v MigrationToV5Done %_Nul2% | find /i "0x1" %_Nul1% && (
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
reg query %kNext% | findstr /i /r "visio.*" %_Nul2% | find /i "0x2" %_Nul1% && set sub_vsio=1
reg query %kNext% | findstr /i /r "visio.*" %_Nul2% | find /i "0x3" %_Nul1% && set sub_vsio=1
)
if %sub_o365% EQU 1 set sub_next=1
if %sub_proj% EQU 1 set sub_next=1
if %sub_vsio% EQU 1 set sub_next=1
if %vNextOverride% EQU 1 if %_Cnvrt% EQU 1 (
set sub_o365=0
set sub_proj=0
set sub_vsio=0
if %sub_next% EQU 1 reg delete HKCU\SOFTWARE\Microsoft\Office\16.0\Common\Licensing /f %_Nul3%
)
set _Retail=0
set "_ocq=ApplicationID='%_oApp%' AND LicenseStatus='1' AND PartialProductKey is not NULL"
@ -408,6 +419,8 @@ echo. @@ -408,6 +419,8 @@ echo.
set _O16O365=0
set _C16Msg=0
set _C15Msg=0
set _C16Vol=0
set _C15Vol=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"
@ -444,24 +457,24 @@ set _%%a=0 @@ -444,24 +457,24 @@ 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)
find /i "Office21%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0&set _C16Vol=1) || (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)
find /i "Office19%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0&set _C16Vol=1) || (set _%%a=1)
)
)
for %%a in (%_V16Ids%) do (
findstr /I /C:"%%aVolume" "!_temp!\crvProductIds.txt" %_Nul1% && (
find /i "Office16%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0) || (set _%%a=1)
find /i "Office16%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0&set _C16Vol=1) || (set _%%a=1)
)
)
reg query %_PRIDs%\ProPlusRetail.16 %_Nul3% && (
find /i "Office16ProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0) || (set _ProPlus=1)
find /i "Office16ProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0&set _C16Vol=1) || (set _ProPlus=1)
)
reg query %_PRIDs%\ProPlusVolume.16 %_Nul3% && (
find /i "Office16ProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0) || (set _ProPlus=1)
find /i "Office16ProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0&set _C16Vol=1) || (set _ProPlus=1)
)
if %_Retail% EQU 1 for %%a in (%_RetIds%) do (
findstr /I /C:"%%aRetail" "!_temp!\crvProductIds.txt" %_Nul1% && (
@ -492,25 +505,25 @@ if %_Retail% EQU 1 reg query %_PRIDs%\ProPlusRetail.16 %_Nul3% && ( @@ -492,25 +505,25 @@ 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%"
set "_qr=%_zz1% %_spp% %_zz2% "ApplicationID='%_oApp%' AND LicenseFamily LIKE 'Office16O365%%'" %_zz3% LicenseFamily %_zz4%"
find /i "Office16MondoVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (
%_qr% %_Nul2% | find /i "O365" %_Nul1% && (
for %%a in (O365ProPlus,O365Business,O365SmallBusPrem,O365HomePrem,O365EduCloud) do set _%%a=0
)
)
if %sub_O365% EQU 1 (
if %sub_o365% EQU 1 (
for %%a in (%_Suites%) do set _%%a=0
echo Microsoft Office is activated with a subscription.
echo Microsoft Office is activated with a vNext license.
echo.
)
if %sub_proj% EQU 1 (
for %%a in (%_PrjSKU%) do set _%%a=0
echo Microsoft Project is activated with a subscription.
echo Microsoft Project is activated with a vNext license.
echo.
)
if %sub_vis% EQU 1 (
if %sub_vsio% EQU 1 (
for %%a in (%_VisSKU%) do set _%%a=0
echo Microsoft Visio is activated with a subscription.
echo Microsoft Visio is activated with a vNext license.
echo.
)
@ -518,6 +531,7 @@ if %_Cnvrt% NEQ 1 (if %_Office15% EQU 1 (goto :R15V) else (set "msg=Finished"&go @@ -518,6 +531,7 @@ if %_Cnvrt% NEQ 1 (if %_Office15% EQU 1 (goto :R15V) else (set "msg=Finished"&go
for %%a in (%_RetIds%,ProPlus) do if !_%%a! EQU 1 (
set _C16Msg=1
set _C16Vol=1
)
if %_C16Msg% EQU 1 (
echo.
@ -747,14 +761,14 @@ findstr /I /C:"%%aRetail" "!_temp!\crvProduct15s.txt" %_Nul1% && set _%%a=1 @@ -747,14 +761,14 @@ findstr /I /C:"%%aRetail" "!_temp!\crvProduct15s.txt" %_Nul1% && set _%%a=1
)
for %%a in (%_V15Ids%) do (
findstr /I /C:"%%aVolume" "!_temp!\crvProduct15s.txt" %_Nul1% && (
find /i "Office%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0) || (set _%%a=1)
find /i "Office%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0&set _C15Vol=1) || (set _%%a=1)
)
)
reg query %_PR15IDs%\Active\ProPlusRetail\x-none %_Nul3% && (
find /i "OfficeProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0) || (set _ProPlus=1)
find /i "OfficeProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0&set _C15Vol=1) || (set _ProPlus=1)
)
reg query %_PR15IDs%\Active\ProPlusVolume\x-none %_Nul3% && (
find /i "OfficeProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0) || (set _ProPlus=1)
find /i "OfficeProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0&set _C15Vol=1) || (set _ProPlus=1)
)
if %_Retail% EQU 1 for %%a in (%_R15Ids%) do (
findstr /I /C:"%%aRetail" "!_temp!\crvProduct15s.txt" %_Nul1% && (
@ -774,7 +788,7 @@ if %_Retail% EQU 1 reg query %_PR15IDs%\Active\ProPlusRetail\x-none %_Nul3% && ( @@ -774,7 +788,7 @@ 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%"
set "_qr=%_zz1% %_spp% %_zz2% "ApplicationID='%_oApp%' AND LicenseFamily LIKE 'OfficeO365%%'" %_zz3% LicenseFamily %_zz4%"
find /i "OfficeMondoVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (
%_qr% %_Nul2% | find /i "O365" %_Nul1% && (
for %%a in (O365ProPlus,O365Business,O365SmallBusPrem,O365HomePrem) do set _%%a=0
@ -785,6 +799,7 @@ if %_Cnvrt% NEQ 1 (set "msg=Finished"&goto :TheEnd) @@ -785,6 +799,7 @@ if %_Cnvrt% NEQ 1 (set "msg=Finished"&goto :TheEnd)
for %%a in (%_R15Ids%,ProPlus) do if !_%%a! EQU 1 (
set _C15Msg=1
set _C15Vol=1
)
if %_C15Msg% EQU 1 if %_C16Msg% EQU 0 (
echo.
@ -941,14 +956,18 @@ set "_qr=wmic path %_sps% where Version='%_wmi%' call RefreshLicenseStatus" @@ -941,14 +956,18 @@ 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 %%#
if %_Retail% EQU 0 (
for %%# in (15) do if !_Loc%%#! EQU 0 call :C2Runi %%#
)
if %_Retail% EQU 0 if %sub_o365% EQU 0 if %sub_proj% EQU 0 if %sub_vsio% EQU 0 (
for %%# in (16,19,21) do if !_Loc%%#! EQU 0 call :C2Runi %%#
)
if %_C15Vol% EQU 1 (
for %%# in (15) do if !_Loc%%#! EQU 1 call :C2Rins %%#
)
if %_C16Vol% EQU 1 (
for %%# in (16,19,21) 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%
@ -965,12 +984,12 @@ set "msg=Finished" @@ -965,12 +984,12 @@ set "msg=Finished"
goto :TheEnd
:C2Runi
set "_qr=%_zz1% %_spp% %_zz2% "Name like 'Office %~1%%' AND PartialProductKey is not NULL" %_zz3% ID %_zz4%"
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
set "_qr=%_zz7% %_spp% %_zz2% %_zz5%Description like 'Office %1, VOLUME_KMSCLIENT%%' AND PartialProductKey is NULL%_zz6% %_zz3% ID %_zz8%"
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

81
OfficeScrubber/Clean_Subscription_Licenses.cmd

@ -1,81 +0,0 @@ @@ -1,81 +0,0 @@
@setlocal DisableDelayedExpansion
@echo off
set _args=
set _args=%*
if not defined _args goto :NoProgArgs
for %%A in (%_args%) do (
if /i "%%A"=="-wow" set _rel1=1
if /i "%%A"=="-arm" set _rel2=1
)
:NoProgArgs
set "_cmdf=%~f0"
if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 (
setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow"
exit /b
)
if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 (
setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm"
exit /b
)
set "SysPath=%SystemRoot%\System32"
if exist "%SystemRoot%\Sysnative\reg.exe" (set "SysPath=%SystemRoot%\Sysnative")
set "Path=%SysPath%;%SystemRoot%;%SysPath%\Wbem;%SysPath%\WindowsPowerShell\v1.0\"
reg query HKU\S-1-5-19 >nul 2>&1 || (
set "msg=ERROR: right click on the script and 'Run as administrator'"
goto :end
)
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
if %winbuild% LSS 7601 (
set "msg=ERROR: Windows 7 SP1 is the minimum supported OS"
goto :end
)
set "_work=%~dp0bin"
setlocal EnableDelayedExpansion
pushd "!_work!"
if not exist "OLicenseCleanup.vbs" (
set "msg=ERROR: required file OLicenseCleanup.vbs is missing"
goto :end
)
set "_Nul1=1>nul"
set "_Nul2=2>nul"
set "_Nul6=2^>nul"
set "_Nul3=1>nul 2>nul"
title Remove Office Subscription Licenses
echo.
echo ============================================================
echo.
echo.
choice /C YN /N /M "Continue with removing Office subscription licenses? [y/n]: "
if errorlevel 2 goto :eof
if errorlevel 1 goto :main
:main
cls
echo.
echo ============================================================
echo Executing OLicenseCleanup.vbs
echo ============================================================
%_Nul3% cscript //Nologo //B OLicenseCleanup.vbs
if %winbuild% GEQ 17133 if exist "WAMAccounts.ps1" (
echo.
echo ============================================================
echo Executing WAMAccounts.ps1
echo ============================================================
%_Nul3% powershell -ep unrestricted -nop -c "try {& .\WAMAccounts.ps1} catch {}"
)
set "msg=Finished. It's recommended to restart the system."
goto :end
:end
echo.
echo ============================================================
echo %msg%
echo ============================================================
echo.
echo Press any key to exit.
pause >nul
goto :eof

276
OfficeScrubber/Full_Scrub.cmd

@ -1,276 +0,0 @@ @@ -1,276 +0,0 @@
<!-- : Begin batch script
@setlocal DisableDelayedExpansion
@echo off
set _args=
set _args=%*
if not defined _args goto :NoProgArgs
for %%A in (%_args%) do (
if /i "%%A"=="-wow" set _rel1=1
if /i "%%A"=="-arm" set _rel2=1
)
:NoProgArgs
set "_cmdf=%~f0"
if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 (
setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow"
exit /b
)
if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 (
setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm"
exit /b
)
set "SysPath=%SystemRoot%\System32"
if exist "%SystemRoot%\Sysnative\reg.exe" (set "SysPath=%SystemRoot%\Sysnative")
set "Path=%SysPath%;%SystemRoot%;%SysPath%\Wbem;%SysPath%\WindowsPowerShell\v1.0\"
reg query HKU\S-1-5-19 >nul 2>&1 || (
set "msg=ERROR: right click on the script and 'Run as administrator'"
goto :end
)
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
if %winbuild% LSS 7601 (
set "msg=ERROR: Windows 7 SP1 is the minimum supported OS"
goto :end
)
set _cwmi=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "ComputerSystem" 1>nul && set _cwmi=1
)
set _pwsh=1
for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" set _pwsh=0
set "_csq=cscript.exe //NoLogo //Job:WmiQuery "%~nx0?.wsf""
set "_csm=cscript.exe //NoLogo //Job:WmiMethod "%~nx0?.wsf""
set WMI_VBS=0
if %_cwmi% EQU 0 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"
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 "_file=%_Common%\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
set "_fil2=%CommonProgramFiles(x86)%\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
set "_work=%~dp0bin"
setlocal EnableDelayedExpansion
pushd "!_work!"
if not exist "%xBit%\cleanospp.exe" (
set "msg=ERROR: required file cleanospp.exe is missing"
goto :end
)
for %%# in (OffScrub_O16msi.vbs,OffScrubC2R.vbs,OLicenseCleanup.vbs) do (
if not exist ".\%%#" (set "msg=ERROR: required file %%# is missing"&goto :end)
)
set "_Nul1=1>nul"
set "_Nul2=2>nul"
set "_Nul6=2^>nul"
set "_Nul3=1>nul 2>nul"
title Office Scrubber
set OfficeC2R=0
sc query ClickToRunSvc %_Nul3% && set OfficeC2R=1
sc query OfficeSvc %_Nul3% && set OfficeC2R=1
reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %_Nul3% && (
set OfficeC2R=1
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v Platform" %_Nul6%') do set "_plat=%%b"
)
if %OfficeC2R% equ 0 reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %_Nul3% && (
set OfficeC2R=1
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\Configuration /v Platform" %_Nul6%') do set "_plat=%%b"
)
if exist "!_file!" set OfficeC2R=1
if exist "!_fil2!" if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" set OfficeC2R=1
set OfficeMSI=0
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\16.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\OSPP.VBS" set OfficeMSI=1
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\16.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\OSPP.VBS" set OfficeMSI=1
if %OfficeC2R% equ 1 if not defined _plat (
if exist "%ProgramFiles(x86)%\Microsoft Office\Office16\OSPP.VBS" (set "_plat=x86") else (set "_plat=%xBit%")
)
set OfficeUWP=0
if %winbuild% GEQ 10240 reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msoxmled.exe" %_Nul3% && (
dir /b "%ProgramFiles%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set OfficeUWP=1
dir /b "%ProgramW6432%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set OfficeUWP=1
dir /b "%ProgramFiles(x86)%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set OfficeUWP=1
)
if %OfficeC2R% equ 0 if %OfficeMSI% equ 0 if %OfficeUWP% equ 0 (
echo.
echo ============================================================
echo No installed Office ClickToRun or Office 2016 MSI detected
echo.
echo.
choice /C YN /N /M "Continue with scrubbing Office anyway? [y/n]: "
if errorlevel 2 goto :eof
if errorlevel 1 goto :main
)
echo.
echo ============================================================
if %OfficeC2R% equ 1 echo Detected Office C2R
if %OfficeMSI% equ 1 echo Detected Office 2016 MSI
if %OfficeUWP% equ 1 echo Detected Office UWP Apps
echo.
echo.
choice /C YN /N /M "Continue with scrubbing detected Office? [y/n]: "
if errorlevel 2 goto :eof
if errorlevel 1 goto :main
:main
cls
if %OfficeC2R% equ 0 if %OfficeMSI% equ 0 if %OfficeUWP% equ 0 goto :proceed
echo.
echo ============================================================
echo Uninstalling Product Key^(s)
echo ============================================================
call :cKMS %_Nul3%
if %WMI_VBS% NEQ 0 cd bin
:proceed
if exist "!_file!" (
echo.
echo ============================================================
echo Executing OfficeClickToRun.exe
echo ============================================================
%_Nul3% start "" /WAIT "!_file!" platform=%_plat% productstoremove=AllProducts displaylevel=False
)
if exist "!_fil2!" if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" (
echo.
echo ============================================================
echo Executing OfficeClickToRun.exe
echo ============================================================
%_Nul3% start "" /WAIT "!_fil2!" platform=%_plat% productstoremove=AllProducts displaylevel=False
)
echo.
echo ============================================================
echo Executing OffScrubC2R.vbs
echo ============================================================
%_Nul3% cscript //Nologo //B OffScrubC2R.vbs ALL /OSE /QUIET /NOCANCEL
echo.
echo ============================================================
echo Executing OffScrub_O16msi.vbs
echo ============================================================
%_Nul3% cscript //Nologo //B OffScrub_O16msi.vbs ALL /OSE /QUIET /NOCANCEL /NOREBOOT /FORCE /DELETEUSERSETTINGS /ECI
echo.
echo ============================================================
echo Executing OLicenseCleanup.vbs
echo ============================================================
%_Nul3% cscript //Nologo //B OLicenseCleanup.vbs
if %winbuild% GEQ 17133 if exist "WAMAccounts.ps1" if %_pwsh% equ 1 (
echo.
echo ============================================================
echo Executing WAMAccounts.ps1
echo ============================================================
%_Nul3% powershell -ep unrestricted -nop -c "try {& .\WAMAccounts.ps1} catch {}"
)
if %OfficeUWP% equ 1 if %_pwsh% equ 1 (
echo.
echo ============================================================
echo Removing Office UWP Apps
echo ============================================================
%_Nul3% powershell -nop -c "Get-AppXPackage -Name '*Microsoft.Office.Desktop*' | Foreach {Remove-AppxPackage $_.PackageFullName}"
%_Nul3% powershell -nop -c "Get-AppXProvisionedPackage -Online | Where DisplayName -Like '*Microsoft.Office.Desktop*' | Remove-AppXProvisionedPackage -Online"
)
%xBit%\cleanospp.exe %_Nul3%
reg delete HKCU\Software\Microsoft\Office /f %_Nul3%
reg delete HKCU\Software\Policies\Microsoft\Office\16.0 /f %_Nul3%
reg delete HKLM\SOFTWARE\Microsoft\Office /f %_Nul3%
reg delete HKLM\SOFTWARE\Policies\Microsoft\Office\16.0 /f %_Nul3%
reg delete HKLM\SOFTWARE\Wow6432Node\Microsoft\Office /f %_Nul3%
reg delete HKLM\SOFTWARE\Wow6432Node\Policies\Microsoft\Office\16.0 /f %_Nul3%
for /f %%# in ('"dir /b %SystemRoot%\temp\ose*.exe" %_Nul6%') do taskkill /t /f /IM %%# %_Nul3%
del /f /q "%SystemRoot%\temp\*" %_Nul3%
del /f /q "%SystemRoot%\temp\*.log" %_Nul3%
del /f /q "%temp%\*.log" %_Nul3%
if exist "%SysPath%\spp\store_test\2.0\tokens.dat" (
echo.
echo ============================================================
echo Refreshing Windows Insider Preview Licenses...
echo ============================================================
echo.
cscript //Nologo //B %SysPath%\slmgr.vbs /rilc
if !ERRORLEVEL! NEQ 0 cscript //Nologo //B %SysPath%\slmgr.vbs /rilc
)
set "msg=Finished. It's recommended to restart the system."
goto :end
:cKMS
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
)
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
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
echo.
echo ============================================================
echo %msg%
echo ============================================================
echo.
echo Press any key to exit.
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>
</package>

633
OfficeScrubber/OfficeScrubber.cmd

@ -0,0 +1,633 @@ @@ -0,0 +1,633 @@
<!-- : Begin batch script
@setlocal DisableDelayedExpansion
@echo off
set _elev=
set _args=
set _args=%*
if not defined _args goto :NoProgArgs
for %%A in (%_args%) do (
if /i "%%A"=="-elevated" set _elev=1
if /i "%%A"=="-wow" set _rel1=1
if /i "%%A"=="-arm" set _rel2=1
)
:NoProgArgs
set "_cmdf=%~f0"
if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 (
setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow"
exit /b
)
if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 (
setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm"
exit /b
)
set "SysPath=%SystemRoot%\System32"
set "Path=%SystemRoot%\System32;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\"
if exist "%SystemRoot%\Sysnative\reg.exe" (
set "SysPath=%SystemRoot%\Sysnative"
set "Path=%SystemRoot%\Sysnative;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%"
)
set "_psc=powershell -nop -c"
1>nul 2>nul reg query HKU\S-1-5-19 && (
goto :Passed
) || (
if defined _elev goto :E_Admin
)
set _PSarg="""%~f0""" %_args% -elevated
set _PSarg=%_PSarg:'=''%
(1>nul 2>nul cscript //NoLogo "%~f0?.wsf" //job:ELAV /File:"%~f0" %_args% -elevated) && (
exit /b
) || (
call setlocal EnableDelayedExpansion
1>nul 2>nul %SysPath%\WindowsPowerShell\v1.0\%_psc% "start cmd.exe -arg '/c \"!_PSarg!\"' -verb runas" && (
exit /b
) || (
goto :E_Admin
)
)
:Passed
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
if %winbuild% LSS 7601 (
set "msg=ERROR: Windows 7 SP1 is the minimum supported OS"
goto :TheEnd
)
set _cwmi=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "ComputerSystem" 1>nul && set _cwmi=1
)
set _pwsh=1
for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" set _pwsh=0
set "_csq=cscript.exe //NoLogo //Job:WmiQuery "%~nx0?.wsf""
set "_csm=cscript.exe //NoLogo //Job:WmiMethod "%~nx0?.wsf""
set WMI_VBS=0
if %_cwmi% EQU 0 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 "OPPk=SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform"
set "SPPk=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
set "_para=ALL /QUIET /OSE /NOCANCEL /FORCE /ENDCURRENTINSTALLS /DELETEUSERSETTINGS /CLEARADDINREG /REMOVELYNC"
if /i "%PROCESSOR_ARCHITECTURE%"=="amd64" set "xBit=x64"&set "xOS=x64"
if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" set "xBit=x86"&set "xOS=A64"
if /i "%PROCESSOR_ARCHITECTURE%"=="x86" if "%PROCESSOR_ARCHITEW6432%"=="" set "xBit=x86"&set "xOS=x86"
if /i "%PROCESSOR_ARCHITEW6432%"=="amd64" set "xBit=x64"&set "xOS=x64"
if /i "%PROCESSOR_ARCHITEW6432%"=="arm64" set "xBit=x86"&set "xOS=A64"
set "_Common=%CommonProgramFiles%"
if defined PROCESSOR_ARCHITEW6432 set "_Common=%CommonProgramW6432%"
set "_file=%_Common%\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
set "_fil2=%CommonProgramFiles(x86)%\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
set "_work=%~dp0bin"
set "_Local=%LocalAppData%"
set "_cscript=cscript //Nologo //B"
setlocal EnableDelayedExpansion
pushd "!_work!"
if not exist "%xBit%\cleanospp.exe" (
set "msg=ERROR: required file cleanospp.exe is missing"
goto :TheEnd
)
for %%# in (OffScrubC2R,OffScrub_O16msi,OffScrub_O15msi,OffScrub10,OffScrub07,OffScrub03) do (
if not exist ".\%%#.vbs" (set "msg=ERROR: required file %%# is missing"&goto :TheEnd)
)
set "_Nul1=1>nul"
set "_Nul2=2>nul"
set "_Nul6=2^>nul"
set "_Nul3=1>nul 2>nul"
title Office Scrubber
echo.
echo ============================================================
echo Detecting Office versions, please wait...
set OsppHook=1
sc query osppsvc %_Nul3%
if %ERRORLEVEL% EQU 1060 set OsppHook=0
for %%A in (11,12,14,15,16) do call :officeMSI %%A
set _O16CTR=0
sc query ClickToRunSvc %_Nul3% && set _O16CTR=1
reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %_Nul3% && (
set _O16CTR=1
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v Platform" %_Nul6%') do set "_plat=%%b"
)
if not %xOS%==x86 if %_O16CTR% EQU 0 reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %_Nul3% && (
set _O16CTR=1
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\Configuration /v Platform" %_Nul6%') do set "_plat=%%b"
)
if exist "!_file!" set _O16CTR=1
if exist "!_fil2!" if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" set _O16CTR=1
if %_O16CTR% EQU 1 if not defined _plat (
if exist "%ProgramFiles(x86)%\Microsoft Office\Office16\OSPP.VBS" (set "_plat=x86") else (set "_plat=%xBit%")
)
set _O15CTR=0
sc query OfficeSvc %_Nul3% && set _O15CTR=1
reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun /v InstallPath %_Nul3% && (
set _O15CTR=1
)
if %_O15CTR% EQU 0 reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun /v InstallPath %_Nul3% && (
set _O15CTR=1
)
if %_O15CTR% EQU 0 reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\propertyBag /v productreleaseid %_Nul3% && (
set _O15CTR=1
)
if %_O15CTR% EQU 0 reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun\propertyBag /v productreleaseid %_Nul3% && (
set _O15CTR=1
)
set _O14CTR=0
if %xOS%==x86 reg query HKLM\SOFTWARE\Microsoft\Office\14.0\CVH /f Click2run /k %_Nul3% && set _O14CTR=1
if not %xOS%==x86 reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\CVH /f Click2run /k %_Nul3% && set _O14CTR=1
set _O16UWP=0
if %winbuild% GEQ 10240 reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msoxmled.exe" %_Nul3% && (
dir /b "%ProgramFiles%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set _O16UWP=1
if not %xOS%==x86 dir /b "%ProgramW6432%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set _O16UWP=1
if not %xOS%==x86 dir /b "%ProgramFiles(x86)%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set _O16UWP=1
)
set kO16=HKCU\SOFTWARE\Microsoft\Office\16.0
set _O16NXT=0
dir /b /s /a:-d "!_Local!\Microsoft\Office\Licenses\*1*" %_Nul3% && set _O16NXT=1
dir /b /s /a:-d "!ProgramData!\Microsoft\Office\Licenses\*1*" %_Nul3% && set _O16NXT=1
reg query "%kO16%\Common\Licensing\LicensingNext" /v MigrationToV5Done %_Nul2% | find /i "0x1" %_Nul1% && set _O16NXT=1
set tOCTR=0&set "dOCTR="
set tOM16=0&set "dOM16="
set tOM15=0&set "dOM15="
set tOM14=0&set "dOM14="
set tOM12=0&set "dOM12="
set tOM11=0&set "dOM11="
set tOUWP=0&set "dOUWP="
set "dONXT="
if %_O15CTR% EQU 1 set tOCTR=1&set "dOCTR={*} / 2013"
if %_O16CTR% EQU 1 set tOCTR=1&set "dOCTR={*}"
if %_O16MSI% EQU 1 set tOM16=1&set "dOM16={*}"
if %_O15MSI% EQU 1 set tOM15=1&set "dOM15={*}"
if %_O14CTR% EQU 1 set tOM14=1&set "dOM14={*} / C2R"
if %_O14MSI% EQU 1 set tOM14=1&set "dOM14={*}"
if %_O12MSI% EQU 1 set tOM12=1&set "dOM12={*}"
if %_O11MSI% EQU 1 set tOM11=1&set "dOM11={*}"
if %_O16UWP% EQU 1 set tOUWP=1&set "dOUWP={*}"
if %_O16NXT% EQU 1 set "dONXT={*}"
:Menu
set _er=0
call :Hdr
echo [1] Scrub ALL
echo [2] Scrub Office C2R %dOCTR%
echo [3] Scrub Office 2016 %dOM16%
echo [4] Scrub Office 2013 %dOM15%
echo [5] Scrub Office 2010 %dOM14%
echo [6] Scrub Office 2007 %dOM12%
echo [7] Scrub Office 2003 %dOM11%
if %winbuild% GEQ 10240 echo [8] Scrub Office UWP %dOUWP%
echo.
echo. --- Office 2016 and later ---
echo [C] Clean vNext Licenses %dONXT%
echo [R] Remove all Licenses
echo [T] Reset C2R Licenses
echo [U] Uninstall all Keys
echo.
echo ============================================================
choice /c 12345678CRTU0 /n /m "Choose a menu option, or press 0 to Exit: "
set _er=%ERRORLEVEL%
if %_er% EQU 13 goto :eof
if %_er% EQU 12 goto :KeysU
if %_er% EQU 11 goto :LcnsT
if %_er% EQU 10 goto :LcnsR
if %_er% EQU 9 goto :LcnsC
if %_er% EQU 8 (if %winbuild% GEQ 10240 (goto :sOUWP) else (goto :Menu))
if %_er% EQU 7 goto :sOM11
if %_er% EQU 6 goto :sOM12
if %_er% EQU 5 goto :sOM14
if %_er% EQU 4 goto :sOM15
if %_er% EQU 3 goto :sOM16
if %_er% EQU 2 goto :sOCTR
if %_er% EQU 1 goto :mALL
goto :Menu
:mALL
set "aOCTR=NO %dOCTR%"
set "aOM16=NO %dOM16%"
set "aOM15=NO %dOM15%"
set "aOM14=NO %dOM14%"
set "aOM12=NO %dOM12%"
set "aOM11=NO %dOM11%"
set "aOUWP=NO %dOUWP%"
if %tOCTR% EQU 1 set "aOCTR=YES %dOCTR%"
if %tOM16% EQU 1 set "aOM16=YES %dOM16%"
if %tOM15% EQU 1 set "aOM15=YES %dOM15%"
if %tOM14% EQU 1 set "aOM14=YES %dOM14%"
if %tOM12% EQU 1 set "aOM12=YES %dOM12%"
if %tOM11% EQU 1 set "aOM11=YES %dOM11%"
if %tOUWP% EQU 1 set "aOUWP=YES %dOUWP%"
set _er=0
call :Hdr
echo [1] Start the operation
echo [2] Office C2R : %aOCTR%
echo [3] Office 2016: %aOM16%
echo [4] Office 2013: %aOM15%
echo [5] Office 2010: %aOM14%
echo [6] Office 2007: %aOM12%
echo [7] Office 2003: %aOM11%
if %winbuild% GEQ 10240 echo [8] Office UWP : %aOUWP%
echo.
echo -------
echo Notice:
echo It's recommended to only scrub detected versions {*}
echo selecting all is not necessary and will take a long time.
echo.
echo ============================================================
choice /c 123456780 /n /m "Change menu options, or press 0 to Exit: "
set _er=%ERRORLEVEL%
if %_er% EQU 9 goto :eof
if %_er% EQU 8 (if %tOUWP% EQU 1 (set tOUWP=0) else (set tOUWP=1)&goto :mALL)
if %_er% EQU 7 (if %tOM11% EQU 1 (set tOM11=0) else (set tOM11=1)&goto :mALL)
if %_er% EQU 6 (if %tOM12% EQU 1 (set tOM12=0) else (set tOM12=1)&goto :mALL)
if %_er% EQU 5 (if %tOM14% EQU 1 (set tOM14=0) else (set tOM14=1)&goto :mALL)
if %_er% EQU 4 (if %tOM15% EQU 1 (set tOM15=0) else (set tOM15=1)&goto :mALL)
if %_er% EQU 3 (if %tOM16% EQU 1 (set tOM16=0) else (set tOM16=1)&goto :mALL)
if %_er% EQU 2 (if %tOCTR% EQU 1 (set tOCTR=0) else (set tOCTR=1)&goto :mALL)
if %_er% EQU 1 goto :sOALL
goto :mALL
:Hdr
cls
echo ============================================================
goto :eof
:sOALL
call :Hdr
echo.
echo Uninstall Product Keys
%xBit%\cleanospp.exe -PKey %_Nul3%
call :cKMS %_Nul3%
if %tOCTR% EQU 1 call :rOCTR
if %tOUWP% EQU 1 if %_pwsh% EQU 1 call :rOUWP
if %tOM16% EQU 1 call :rOM16
if %tOM15% EQU 1 call :rOM15
if %tOM14% EQU 1 call :rOM14
if %tOM12% EQU 1 call :rOM12
if %tOM11% EQU 1 call :rOM11
call :cSPP
goto :Fin
:sOCTR
call :Hdr
call :rOCTR
if %_O15MSI% EQU 0 call :cSPP
goto :Fin
:sOM16
call :Hdr
call :rOM16
if %_O15MSI% EQU 0 call :cSPP
goto :Fin
:sOM15
call :Hdr
call :rOM15
if %_O16MSI% EQU 0 if %_O16CTR% EQU 0 if %_O16UWP% EQU 0 call :cSPP
goto :Fin
:sOM14
call :Hdr
call :rOM14
goto :Fin
:sOM12
call :Hdr
call :rOM12
goto :Fin
:sOM11
call :Hdr
call :rOM11
goto :Fin
:sOUWP
call :Hdr
if %_pwsh% EQU 0 (
set "msg=ERROR: Windows Powershell is not detected."
goto :TheEnd
)
call :rOUWP
set "msg=Done."
goto :TheEnd
:rOCTR
if exist "!_file!" (
echo.
echo Execute OfficeClickToRun.exe
%_Nul3% start "" /WAIT "!_file!" platform=%_plat% productstoremove=AllProducts displaylevel=False
)
if exist "!_fil2!" if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" (
echo.
echo Execute OfficeClickToRun.exe
%_Nul3% start "" /WAIT "!_fil2!" platform=%_plat% productstoremove=AllProducts displaylevel=False
)
echo.
echo Scrub Office C2R
for %%A in (16,19,21) do call :cKpp %%A
if %_O15CTR% EQU 1 call :cKpp 15
%_Nul3% %_cscript% OffScrubC2R.vbs ALL /QUIET /OFFLINE
%_Nul3% call :vNextDir
%_Nul3% call :officeREG 16
goto :eof
:rOUWP
echo.
echo Remove Office UWP Apps
%_Nul3% %_psc% "Get-AppXPackage -Name '*Microsoft.Office.Desktop*' | Foreach {Remove-AppxPackage $_.PackageFullName}"
%_Nul3% %_psc% "Get-AppXProvisionedPackage -Online | Where DisplayName -Like '*Microsoft.Office.Desktop*' | Remove-AppXProvisionedPackage -Online"
goto :eof
:rOM16
echo.
echo Scrub Office 2016 MSI
call :cKpp 16
%_Nul3% %_cscript% OffScrub_O16msi.vbs %_para%
%_Nul3% call :officeREG 16
goto :eof
:rOM15
echo.
echo Scrub Office 2013 MSI
call :cKpp 15
%_Nul3% %_cscript% OffScrub_O15msi.vbs %_para%
%_Nul3% call :officeREG 15
goto :eof
:rOM14
echo.
echo Scrub Office 2010
call :cK14
%_Nul3% %_cscript% OffScrub10.vbs %_para%
%_Nul3% call :officeREG 14
goto :eof
:rOM12
echo.
echo Scrub Office 2007
%_Nul3% %_cscript% OffScrub07.vbs %_para%
%_Nul3% call :officeREG 12
goto :eof
:rOM11
echo.
echo Scrub Office 2003
%_Nul3% %_cscript% OffScrub03.vbs %_para%
%_Nul3% call :officeREG 11
goto :eof
:cSPP
%xBit%\cleanospp.exe %_Nul3%
call :slmgr
goto :eof
:slmgr
if exist "%SysPath%\spp\store_test\2.0\tokens.dat" (
echo.
echo Refresh Windows Insider Preview Licenses
%_cscript% %SysPath%\slmgr.vbs /rilc %_Nul3%
if !ERRORLEVEL! NEQ 0 %_cscript% %SysPath%\slmgr.vbs /rilc %_Nul3%
)
goto :eof
:Fin
for /f %%# in ('"dir /b %SystemRoot%\temp\ose*.exe" %_Nul6%') do taskkill /t /f /IM %%# %_Nul3%
del /f /q "%SystemRoot%\temp\ose*.exe" %_Nul3%
set "msg=Finished. It's recommended to restart the system."
goto :TheEnd
:officeMSI
set _O%1MSI=0
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\*.dll" set _O%1MSI=1
if exist "%ProgramFiles%\Microsoft Office\Office%1\*.dll" set _O%1MSI=1
if %xOS%==x86 goto :eof
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\*.dll" set _O%1MSI=1
if exist "%ProgramW6432%\Microsoft Office\Office%1\*.dll" set _O%1MSI=1
if exist "%ProgramFiles(x86)%\Microsoft Office\Office%1\*.dll" set _O%1MSI=1
goto :eof
:officeREG
reg delete HKCU\Software\Microsoft\Office\%1.0 /f
reg delete HKCU\Software\Policies\Microsoft\Office\%1.0 /f
reg delete HKLM\SOFTWARE\Microsoft\Office\%1.0 /f
reg delete HKLM\SOFTWARE\Policies\Microsoft\Office\%1.0 /f
reg delete HKLM\SOFTWARE\Microsoft\Office\%1.0 /f /reg:32
reg delete HKLM\SOFTWARE\Policies\Microsoft\Office\%1.0 /f /reg:32
goto :eof
:cK14
if %_WSH% EQU 0 if %WMI_VBS% NEQ 0 goto :eof
if %WMI_VBS% NEQ 0 cd ..
set _spp=OfficeSoftwareProtectionProduct
if %OsppHook% NEQ 0 (
call :cKEY 14
)
if %WMI_VBS% NEQ 0 cd bin
goto :eof
:cKpp
if %_WSH% EQU 0 if %WMI_VBS% NEQ 0 goto :eof
if %WMI_VBS% NEQ 0 cd ..
set _spp=SoftwareLicensingProduct
if %winbuild% GEQ 9200 (
call :cKEY %1
)
set _spp=OfficeSoftwareProtectionProduct
if %winbuild% LSS 9200 if %OsppHook% NEQ 0 (
call :cKEY %1
)
if %WMI_VBS% NEQ 0 cd bin
goto :eof
:cKMS
if %_WSH% EQU 0 if %WMI_VBS% NEQ 0 goto :eof
if %WMI_VBS% NEQ 0 cd ..
set _spp=SoftwareLicensingProduct
if %winbuild% GEQ 9200 (
reg delete "HKLM\%SPPk%\%_oApp%" /f
reg delete "HKLM\%SPPk%\%_oApp%" /f /reg:32
reg delete "HKEY_USERS\S-1-5-20\%SPPk%\%_oApp%" /f
for %%A in (15,16,19,21) do call :cKEY %%A
)
set _spp=OfficeSoftwareProtectionProduct
if %winbuild% GEQ 9200 if %OsppHook% NEQ 0 (
call :cKEY 14
)
if %winbuild% LSS 9200 if %OsppHook% NEQ 0 (
reg delete "HKLM\%OPPk%\%_oApp%" /f
reg delete "HKLM\%OPPk%\%_oApp%" /f /reg:32
for %%A in (14,15,16,19,21) do call :cKEY %%A
)
reg delete "HKLM\%OPPk%\%_oA14%" /f
reg delete "HKEY_USERS\S-1-5-20\%OPPk%" /f
if %WMI_VBS% NEQ 0 cd bin
goto :eof
:cKEY
set "_ocq=Name LIKE 'Office %~1%%' 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==" %%# in ('%_qr% %_Nul6%') do (set "aID=%%#"&call :cAPP)
goto :eof
:cAPP
set "_qr=wmic path %_spp% where ID='%aID%' call UninstallProductKey"
if %WMI_VBS% NEQ 0 set "_qr=%_csm% "%_spp%.ID='%aID%'" UninstallProductKey"
%_qr% %_Nul3%
goto :eof
:vNextDir
attrib -R "!ProgramData!\Microsoft\Office\Licenses"
attrib -R "!_Local!\Microsoft\Office\Licenses"
rd /s /q "!ProgramData!\Microsoft\Office\Licenses\"
rd /s /q "!_Local!\Microsoft\Office\Licenses\"
goto :eof
:vNextREG
reg delete "%kO16%\Common\Licensing" /f
reg delete "%kO16%\Registration" /f
goto :eof
:LcnsC
call :Hdr
echo.
echo Clean vNext Licenses
%_Nul3% call :vNextDir
%_Nul3% call :vNextREG
set "msg=Done."
goto :TheEnd
:KeysU
call :Hdr
echo.
echo Uninstall Product Keys
%xBit%\cleanospp.exe -PKey %_Nul3%
for %%A in (15,16,19,21) do call :cKpp %%A
set "msg=Done."
goto :TheEnd
:LcnsR
call :Hdr
echo.
echo Remove Office Licenses
%xBit%\cleanospp.exe -Licenses %_Nul3%
call :slmgr
set "msg=Done."
goto :TheEnd
:LcnsT
call :Hdr
echo.
echo Reset Office C2R Licenses
if %_O16CTR% equ 0 (
set "msg=ERROR: No installed Office ClickToRun detected."
goto :TheEnd
)
set "_InstallRoot="
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 (set "_GUID=%%b")
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")
set "_PRIDs=HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\ProductReleaseIDs"
)
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 not exist "%_Integrator%" (
set "msg=ERROR: Could not detect Office Licenses Integrator.exe"
goto :TheEnd
)
for /f "tokens=8 delims=\" %%a in ('reg query "%_PRIDs%" /f ".16" /k %_Nul6% ^| find /i "ClickToRun"') do (
if not defined _SKUs (set "_SKUs=%%a") else (set "_SKUs=!_SKUs!,%%a")
)
if not defined _SKUs (
set "msg=ERROR: Could not detect originally installed Office Products."
goto :TheEnd
)
echo.
echo Remove Office Licenses
%xBit%\cleanospp.exe -Licenses %_Nul3%
call :slmgr
echo.
echo Install Office C2R Licenses
for %%a in (%_SKUs%) do (
"!_Integrator!" /R /License PRIDName=%%a.16 PackageGUID="%_GUID%" PackageRoot="!_InstallRoot!" %_Nul1%
)
set "msg=Done."
goto :TheEnd
:E_Admin
set "msg=ERROR: This script requires administrator privileges."
goto :TheEnd
:TheEnd
echo.
echo ============================================================
echo %msg%
echo.
echo Press any key to exit.
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="ELAV">
<script language="VBScript">
Set strArg=WScript.Arguments.Named
Set strRdlproc = CreateObject("WScript.Shell").Exec("rundll32 kernel32,Sleep")
With GetObject("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" & strRdlproc.ProcessId & "'")
With GetObject("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" & .ParentProcessId & "'")
If InStr (.CommandLine, WScript.ScriptName) <> 0 Then
strLine = Mid(.CommandLine, InStr(.CommandLine , "/File:") + Len(strArg("File")) + 8)
End If
End With
.Terminate
End With
CreateObject("Shell.Application").ShellExecute "cmd.exe", "/c " & chr(34) & chr(34) & strArg("File") & chr(34) & strLine & chr(34), "", "runas", 1
</script>
</job>
</package>

86
OfficeScrubber/README.md

@ -1,34 +1,84 @@ @@ -1,34 +1,84 @@
# Office Scrubber
* An automated scripts to uninstall, remove and scrub Office 2016 MSI and Office Click-to-Run 16.0
* An automated script to uninstall, remove and scrub Microsoft Office (MSI or Click-to-Run)
* It mostly execute OffScrub vbs scripts, obtained from SaRA tool (Microsoft Support and Recovery Assistant)
* Office (2021, 2019, 2016, 365) all share the same installation location and licensing level, which may lead to licenses confliction or duplication
* Additionally, if you uninstalled Office normally on Windows 8/8.1/10, the licenses will be left installed in the system SPP token store
Additionally, if you uninstalled Office 2013+ normally on Windows 8 or later, the licenses will be left installed in the system SPP token store
## Scrub ALL Overview
* By default, this operation will remove the detected Office versions only
in addition to uninstalling product keys, and clean licenses leftovers
* However, you can use the numbers 2-8 to toggle the state for menu options
and force to scrub or skip that Office version
* It's recommended to only scrub the detected versions {*}
selecting all is not necessary and will take a long time.
## Main Options Overview
* Scrub ALL
uninstall and remove one or more Office versions
* Scrub Office C2R
uninstall and remove Office Click-to-Run (365, 2021, LTSC, 2019, 2016, 2013)
the operation will be executed regardless if this Office is detected or not
* Scrub Office 2016
uninstall and remove Office 2016 MSI version
the operation will be executed regardless if this Office is detected or not
* Scrub Office 2013
## Usage:
uninstall and remove Office 2013 MSI version
the operation will be executed regardless if this Office is detected or not
* Full_Scrub.cmd
completely uninstall and remove Office
* Scrub Office 2010
* Uninstall_Keys.cmd
uninstall Office product keys (in case of confliction)
uninstall and remove Office 2010 MSI or C2R version
the operation will be executed regardless if this Office is detected or not
* Remove_Licenses.cmd
clean Office licenses (in case of confliction)
* Scrub Office 2007
you can then repair Office to restore original licenses, or use C2R-R2V to install proper licenses
uninstall and remove Office 2007
the operation will be executed regardless if this Office is detected or not
* Reset_Licenses.cmd
clean Office licenses, and then reinstall original licenses
* Scrub Office 2003
uninstall and remove Office 2003
the operation will be executed regardless if this Office is detected or not
* Scrub Office UWP
uninstall and remove Office Store Apps on Windows 11/10
the operation will be executed regardless if this Office is detected or not
## Extra Options Overview
* Clean vNext Licenses
remove Office vNext licenses (subscription or lifetime), tokens and cached identities
* Remove all Licenses
remove licenses for Office 2013 and later (in case of confliction)
you can then repair Office to restore original licenses, or use C2R-R2V to install Office C2R licenses
* Reset C2R Licenses
remove licenses for Office 2016 and later, and then reinstall original Office C2R licenses
you can use this in case Office repair failed to restore original licenses,
or to remove C2R-R2V Volume licenses and restore original Retail licenses
* Clean_Subscription_Licenses.cmd
clean Office subscription licenses, credentials, tokens and cached identities
it simply execute OLicenseCleanup.vbs
https://docs.microsoft.com/en-us/office/troubleshoot/activation/reset-office-365-proplus-activation-state
* Uninstall all Keys
for Windows 10 version 1803 or later, it also execute WAMAccounts.ps1 (SignOutOfWAMAccounts.ps1)
uninstall product keys for Office 2013 and later (in case of confliction)

126
OfficeScrubber/Remove_Licenses.cmd

@ -1,126 +0,0 @@ @@ -1,126 +0,0 @@
@setlocal DisableDelayedExpansion
@echo off
set _args=
set _args=%*
if not defined _args goto :NoProgArgs
for %%A in (%_args%) do (
if /i "%%A"=="-wow" set _rel1=1
if /i "%%A"=="-arm" set _rel2=1
)
:NoProgArgs
set "_cmdf=%~f0"
if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 (
setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow"
exit /b
)
if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 (
setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm"
exit /b
)
set "SysPath=%SystemRoot%\System32"
if exist "%SystemRoot%\Sysnative\reg.exe" (set "SysPath=%SystemRoot%\Sysnative")
set "Path=%SysPath%;%SystemRoot%;%SysPath%\Wbem;%SysPath%\WindowsPowerShell\v1.0\"
reg query HKU\S-1-5-19 >nul 2>&1 || (
set "msg=ERROR: right click on the script and 'Run as administrator'"
goto :end
)
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
if %winbuild% LSS 7601 (
set "msg=ERROR: Windows 7 SP1 is the minimum supported OS"
goto :end
)
set "_Common=%CommonProgramFiles%"
if defined PROCESSOR_ARCHITEW6432 set "_Common=%CommonProgramW6432%"
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 "_file=%_Common%\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
set "_fil2=%CommonProgramFiles(x86)%\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
set "_work=%~dp0bin"
setlocal EnableDelayedExpansion
pushd "!_work!"
if not exist "%xBit%\cleanospp.exe" (
set "msg=ERROR: required file cleanospp.exe is missing"
goto :end
)
set "_Nul1=1>nul"
set "_Nul2=2>nul"
set "_Nul6=2^>nul"
set "_Nul3=1>nul 2>nul"
title Remove Office Licenses
set OfficeC2R=0
sc query ClickToRunSvc %_Nul3% && set OfficeC2R=1
sc query OfficeSvc %_Nul3% && set OfficeC2R=1
reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %_Nul3% && (
set OfficeC2R=1
)
reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %_Nul3% && (
set OfficeC2R=1
)
if exist "!_file!" set OfficeC2R=1
if exist "!_fil2!" if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" set OfficeC2R=1
set OfficeMSI=0
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\16.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\OSPP.VBS" set OfficeMSI=1
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\16.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\OSPP.VBS" set OfficeMSI=1
set OfficeUWP=0
if %winbuild% GEQ 10240 reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msoxmled.exe" %_Nul3% && (
dir /b "%ProgramFiles%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set OfficeUWP=1
dir /b "%ProgramW6432%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set OfficeUWP=1
dir /b "%ProgramFiles(x86)%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set OfficeUWP=1
)
if %OfficeC2R% equ 0 if %OfficeMSI% equ 0 if %OfficeUWP% equ 0 (
echo.
echo ============================================================
echo No installed Office ClickToRun or Office 2016 MSI detected
echo.
echo.
choice /C YN /N /M "Continue with removing Office licenses anyway? [y/n]: "
if errorlevel 2 goto :eof
if errorlevel 1 goto :main
)
echo.
echo ============================================================
if %OfficeC2R% equ 1 echo Detected Office C2R
if %OfficeMSI% equ 1 echo Detected Office 2016 MSI
if %OfficeUWP% equ 1 echo Detected Office UWP Apps
echo.
echo.
choice /C YN /N /M "Continue with removing detected Office licenses? [y/n]: "
if errorlevel 2 goto :eof
if errorlevel 1 goto :main
:main
cls
echo.
echo ============================================================
echo Cleaning Office Licenses...
echo ============================================================
echo.
%xBit%\cleanospp.exe -Licenses %_Nul3%
if exist "%SysPath%\spp\store_test\2.0\tokens.dat" (
echo.
echo ============================================================
echo Refreshing Windows Insider Preview Licenses...
echo ============================================================
echo.
cscript //Nologo //B %SysPath%\slmgr.vbs /rilc
if !ERRORLEVEL! NEQ 0 cscript //Nologo //B %SysPath%\slmgr.vbs /rilc
)
set "msg=Finished."
goto :end
:end
echo.
echo ============================================================
echo %msg%
echo ============================================================
echo.
echo Press any key to exit.
pause >nul
goto :eof

130
OfficeScrubber/Reset_Licenses.cmd

@ -1,130 +0,0 @@ @@ -1,130 +0,0 @@
@setlocal DisableDelayedExpansion
@echo off
set _args=
set _args=%*
if not defined _args goto :NoProgArgs
for %%A in (%_args%) do (
if /i "%%A"=="-wow" set _rel1=1
if /i "%%A"=="-arm" set _rel2=1
)
:NoProgArgs
set "_cmdf=%~f0"
if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 (
setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow"
exit /b
)
if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 (
setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm"
exit /b
)
set "SysPath=%SystemRoot%\System32"
if exist "%SystemRoot%\Sysnative\reg.exe" (set "SysPath=%SystemRoot%\Sysnative")
set "Path=%SysPath%;%SystemRoot%;%SysPath%\Wbem;%SysPath%\WindowsPowerShell\v1.0\"
reg query HKU\S-1-5-19 >nul 2>&1 || (
set "msg=ERROR: right click on the script and 'Run as administrator'"
goto :end
)
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
if %winbuild% LSS 7601 (
set "msg=ERROR: Windows 7 SP1 is the minimum supported OS"
goto :end
)
set "_Common=%CommonProgramFiles%"
if defined PROCESSOR_ARCHITEW6432 set "_Common=%CommonProgramW6432%"
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 "_file=%_Common%\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
set "_fil2=%CommonProgramFiles(x86)%\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
set "_work=%~dp0bin"
setlocal EnableDelayedExpansion
pushd "!_work!"
if not exist "%xBit%\cleanospp.exe" (
set "msg=ERROR: required file cleanospp.exe is missing"
goto :end
)
set "_Nul1=1>nul"
set "_Nul2=2>nul"
set "_Nul6=2^>nul"
set "_Nul3=1>nul 2>nul"
title Reset Office C2R Licenses
set OfficeC2R=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 OfficeC2R=1
if %OfficeC2R% equ 0 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 OfficeC2R=1
if exist "!_file!" set OfficeC2R=1
if exist "!_fil2!" if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" set OfficeC2R=1
if %OfficeC2R% equ 0 (
set "msg=No installed Office ClickToRun detected"
goto :end
)
:main
set "_InstallRoot="
set "_ProductIds="
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 (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 "_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 not exist "%_Integrator%" (
set "msg=ERROR: Could not detect Office Licenses Integrator.exe"
goto :end
)
for /f "tokens=8 delims=\" %%a in ('reg query "%_PRIDs%" /f ".16" /k %_Nul6% ^| find /i "ClickToRun"') do (
if not defined _SKUs (set "_SKUs=%%a") else (set "_SKUs=!_SKUs!,%%a")
)
if not defined _SKUs (
set "msg=ERROR: Could not detect originally installed Office Products"
goto :end
)
cls
echo.
echo ============================================================
echo Cleaning Office Licenses...
echo ============================================================
echo.
%xBit%\cleanospp.exe -Licenses %_Nul3%
if exist "%SysPath%\spp\store_test\2.0\tokens.dat" (
echo.
echo ============================================================
echo Refreshing Windows Insider Preview Licenses...
echo ============================================================
echo.
cscript //Nologo //B %SysPath%\slmgr.vbs /rilc
if !ERRORLEVEL! NEQ 0 cscript //Nologo //B %SysPath%\slmgr.vbs /rilc
)
echo.
echo ============================================================
echo Installing Office C2R Licenses...
echo ============================================================
echo.
for %%a in (%_SKUs%) do (
"!_Integrator!" /R /License PRIDName=%%a.16 PackageGUID="%_GUID%" PackageRoot="!_InstallRoot!" %_Nul1%
)
set "msg=Finished."
goto :end
:end
echo.
echo ============================================================
echo %msg%
echo ============================================================
echo.
echo Press any key to exit.
pause >nul
goto :eof

208
OfficeScrubber/Uninstall_Keys.cmd

@ -1,208 +0,0 @@ @@ -1,208 +0,0 @@
<!-- : Begin batch script
@setlocal DisableDelayedExpansion
@echo off
set _args=
set _args=%*
if not defined _args goto :NoProgArgs
for %%A in (%_args%) do (
if /i "%%A"=="-wow" set _rel1=1
if /i "%%A"=="-arm" set _rel2=1
)
:NoProgArgs
set "_cmdf=%~f0"
if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 (
setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow"
exit /b
)
if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 (
setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm"
exit /b
)
set "SysPath=%SystemRoot%\System32"
if exist "%SystemRoot%\Sysnative\reg.exe" (set "SysPath=%SystemRoot%\Sysnative")
set "Path=%SysPath%;%SystemRoot%;%SysPath%\Wbem;%SysPath%\WindowsPowerShell\v1.0\"
reg query HKU\S-1-5-19 >nul 2>&1 || (
set "msg=ERROR: right click on the script and 'Run as administrator'"
goto :end
)
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
if %winbuild% LSS 7601 (
set "msg=ERROR: Windows 7 SP1 is the minimum supported OS"
goto :end
)
set _cwmi=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "ComputerSystem" 1>nul && set _cwmi=1
)
set "_csq=cscript.exe //NoLogo //Job:WmiQuery "%~nx0?.wsf""
set "_csm=cscript.exe //NoLogo //Job:WmiMethod "%~nx0?.wsf""
set WMI_VBS=0
if %_cwmi% EQU 0 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"
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 "_file=%_Common%\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
set "_fil2=%CommonProgramFiles(x86)%\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
set "_work=%~dp0bin"
setlocal EnableDelayedExpansion
pushd "!_work!"
if not exist "%xBit%\cleanospp.exe" (
set "msg=ERROR: required file cleanospp.exe is missing"
goto :end
)
set "_Nul1=1>nul"
set "_Nul2=2>nul"
set "_Nul6=2^>nul"
set "_Nul3=1>nul 2>nul"
title Uninstall Office Keys
set OfficeC2R=0
sc query ClickToRunSvc %_Nul3% && set OfficeC2R=1
sc query OfficeSvc %_Nul3% && set OfficeC2R=1
reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %_Nul3% && (
set OfficeC2R=1
)
reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %_Nul3% && (
set OfficeC2R=1
)
if exist "!_file!" set OfficeC2R=1
if exist "!_fil2!" if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" set OfficeC2R=1
set OfficeMSI=0
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\16.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\OSPP.VBS" set OfficeMSI=1
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\16.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\OSPP.VBS" set OfficeMSI=1
set OfficeUWP=0
if %winbuild% GEQ 10240 reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msoxmled.exe" %_Nul3% && (
dir /b "%ProgramFiles%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set OfficeUWP=1
dir /b "%ProgramW6432%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set OfficeUWP=1
dir /b "%ProgramFiles(x86)%\WindowsApps\Microsoft.Office.Desktop*" %_Nul3% && set OfficeUWP=1
)
if %OfficeC2R% equ 0 if %OfficeMSI% equ 0 if %OfficeUWP% equ 0 (
echo.
echo ============================================================
echo No installed Office ClickToRun or Office 2016 MSI detected
echo.
echo.
choice /C YN /N /M "Continue with uninstalling Office keys anyway? [y/n]: "
if errorlevel 2 goto :eof
if errorlevel 1 goto :main
)
echo.
echo ============================================================
if %OfficeC2R% equ 1 echo Detected Office C2R
if %OfficeMSI% equ 1 echo Detected Office 2016 MSI
if %OfficeUWP% equ 1 echo Detected Office UWP Apps
echo.
echo.
choice /C YN /N /M "Continue with uninstalling detected Office keys? [y/n]: "
if errorlevel 2 goto :eof
if errorlevel 1 goto :main
:main
cls
echo.
echo ============================================================
echo Uninstalling Product Key^(s)
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 ============================================================
echo Refreshing Windows Insider Preview Licenses...
echo ============================================================
echo.
cscript //Nologo //B %SysPath%\slmgr.vbs /rilc
if !ERRORLEVEL! NEQ 0 cscript //Nologo //B %SysPath%\slmgr.vbs /rilc
)
set "msg=Finished."
goto :end
:cKMS
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
)
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
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
echo.
echo ============================================================
echo %msg%
echo ============================================================
echo.
echo Press any key to exit.
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>
</package>

697
OfficeScrubber/bin/OLicenseCleanup.vbs

@ -1,697 +0,0 @@ @@ -1,697 +0,0 @@
'*******************************************************************************
' Name: OLicenseCleanup.vbs - v 1.24
' Author: Microsoft Customer Support Services
' Copyright (c) Microsoft Corporation
'
' Removes all licenses for Office 2013 and 2016
' from the (Office) Software Protection Platform
'*******************************************************************************
'Option Explicit
Dim oProductInstances, oWmiLocal, oReg, oWShell, oFso
Dim sQuery, sTemp, sLogDir, sOSinfo, sProfilesDirectory, sCurDir
Dim f64, fO64, fCScript, fQuiet, fClearO15, fClearO16, fSafeForRoamingUsers
Dim fClearUserIdentityCache, fSignOutOfWAM
Dim LogStream
Const SKUFILTER = "O365" 'Removes all licenses that contain O365 in their name
'Note: SKUFILTER = "" 'Removes all licenses
' SKUFILTER = "NOTO365" 'Removes all licenses that do not contain O365 in their name
Const PS_WAMSIGNOUT = "SignOutOfWAMAccounts.ps1"
fQuiet = True
fClearO15 = True
fClearO16 = True
fClearUserIdentityCache = False
fSignOutOfWAM = True
sLogDir = "" 'Custom log folder/directory. No trailing "\" in the path!
'Set this to False if the script needs to run more than once and you don't
'have roaming profile users
fSafeForRoamingUsers = True
'*******************************************************************************
Const OfficeAppId = "0ff1ce15-a989-479d-af46-f275c6370663" 'Office 2013/2016
Const HKLM = &H80000002
Const SCRIPTVERSION = "1.24"
' MAIN
On Error Resume Next
Set oWShell = CreateObject("WScript.Shell")
Initialize
LogH2 "Cleanup start"
CleanOSPP SKUFILTER
ResetUserKey "Common\Identity", "" '"ResetIdentity"
ResetUserKey "Common\Internet\WebServiceCache", "" '"ResetWebServiceCache
ResetUserKey "Common\ServicesManagerCache", "" '"ResetServicesManagerCache"
ResetUserKey "Common\Licensing", "" '"ResetUserLicense"
ResetUserKey "Registration", "" '"ResetUserRegistration"
ClearCredmanCache
ClearSCALicCache
ClearConfigUser
ClearVNextLicCache
If fClearUserIdentityCache Then ClearIdentityCache
If fSignOutOfWAM Then InvokeSignOutOfWAM
LogH2 "Cleanup end"
' END
'-------------------------------------------------------------------------------
' Initialize
'
' Initialize script settings
'-------------------------------------------------------------------------------
Sub Initialize
Dim ComputerItem, Item
Dim sOsVersion
'Check if we're running as 32 bit process on a 64 bit OS
If InStr(LCase(wscript.path), "syswow64") > 0 Then RelaunchAs64Host
Set oWmiLocal = GetObject("winmgmts:\\.\root\cimv2")
Set oReg = GetObject("winmgmts:\\.\root\default:StdRegProv")
Set oFso = CreateObject("Scripting.FileSystemObject")
sTemp = oWShell.ExpandEnvironmentStrings("%TEMP%")
fCScript = (UCase(Mid(Wscript.FullName, Len(Wscript.Path) + 2, 1)) = "C")
' get Win32_OperatingSystem details
'----------------------------------
Set ComputerItem = oWmiLocal.ExecQuery("Select * from Win32_OperatingSystem")
For Each Item in ComputerItem
sOSinfo = sOSinfo & Item.Caption
sOSinfo = sOSinfo & Item.OtherTypeDescription
sOSinfo = sOSinfo & ", " & "SP " & Item.ServicePackMajorVersion
sOSinfo = sOSinfo & ", " & "Version: " & Item.Version
sOsVersion = Item.Version
sOSinfo = sOSinfo & ", " & "Codepage: " & Item.CodeSet
sOSinfo = sOSinfo & ", " & "Country Code: " & Item.CountryCode
sOSinfo = sOSinfo & ", " & "Language: " & Item.OSLanguage
Next
DetectOSBitness
DetectOfficeBitness
CreateLog
LogOnly "Remove O15 Lic: " & fClearO15
LogOnly "Remove O16 Lic: " & fClearO16
LogOnly "Quiet mode: " & fQuiet
RegReadExpStringValue HKLM, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList", "ProfilesDirectory", sProfilesDirectory
If NOT oFso.FolderExists(sProfilesDirectory) Then
sProfilesDirectory = oFso.GetParentFolderName(oWShell.ExpandEnvironmentStrings("%userprofile%"))
End If
LogOnly "Users profile location: " & sProfilesDirectory
sCurDir = Left(WScript.ScriptFullName, InStrRev( WScript.ScriptFullName, "\"))
LogOnly "Current Directory: " & sCurDir
End Sub
'-------------------------------------------------------------------------------
' ClearConfigUser
'
' clear HKLM cached user license id
'-------------------------------------------------------------------------------
Sub ClearConfigUser
Dim value
Dim sConfigKey, sRetVal, sCmd
Dim arrNames, arrTypes
If NOT fClearO16 Then Exit Sub
sConfigKey = "SOFTWARE\Microsoft\Office\ClickToRun\Configuration"
If RegEnumValues(HKLM, sConfigKey, arrNames, arrTypes) Then
For Each value in arrNames
If (InStr(LCase(value), LCase(".EmailAddress")) > 0) Or (InStr(LCase(value), LCase(".TenantId")) > 0) Or (LCase(value) = "productkeys") Then
sCmd = "REG DELETE HKLM\" & sConfigKey & " /v " & value & " /f"
sRetVal = oWShell.Run(sCmd, 0, True)
Log "Remove entry: HKLM\" & sConfigKey & "\" & value
End If
Next
End If
End Sub 'ClearConfigUser
'-------------------------------------------------------------------------------
' ClearSCALicCache
'
' clear local license cache for SharedComputerActivation
'-------------------------------------------------------------------------------
Sub ClearSCALicCache
Dim sLocalAppData, sValue
sLocalAppData = oWShell.ExpandEnvironmentStrings("%localappdata%")
If fClearO15 Then ClearFolder sLocalAppData & "\Microsoft\Office\15.0\Licensing"
If fClearO16 Then ClearFolder sLocalAppData & "\Microsoft\Office\16.0\Licensing"
'Check for custom token location
If RegReadStringValue(HKLM, "Software\Microsoft\Office\16.0\Common\Licensing", "SCLCacheOverrideDirectory", sValue) Then
ClearSCAFolder sValue
End If
End Sub 'ClearSCALicCache
'-------------------------------------------------------------------------------
' ClearVNextLicCache
'
' clear local license cache for vNext
'-------------------------------------------------------------------------------
Sub ClearVNextLicCache
Dim sLocalAppData, sValue
sLocalAppData = oWShell.ExpandEnvironmentStrings("%localappdata%")
ClearFolder sLocalAppData & "\Microsoft\Office\Licenses"
End Sub 'ClearSCALicCache
'-------------------------------------------------------------------------------
' ClearIdentityCache
'
' clear users Windows Identity cache
'-------------------------------------------------------------------------------
Sub ClearIdentityCache
Dim sLocalAppData, sValue
sLocalAppData = oWShell.ExpandEnvironmentStrings("%localappdata%")
ClearFolder sLocalAppData & "\Microsoft\IdentityCache\1\UD"
End Sub 'ClearIdentityCache
'-------------------------------------------------------------------------------
' InvokeSignOutOfWAM
'
' invokes the external script SignOutOfWAMAccounts.ps1 if the script is found
' in the same directory
'-------------------------------------------------------------------------------
Sub InvokeSignOutOfWAM
Dim sCmd, sRetVal
If oFso.FileExists(sScriptDir & PS_WAMSIGNOUT) Then
sCmd = "powershell.exe -executionpolicy unrestricted -noprofile -windowstyle hidden -file " & chr(34) & sCurDir & PS_WAMSIGNOUT & chr(34) & " " & sUITask & " ; exit $LASTEXITCODE"
Log " Running: " & sCmd
On Error Resume Next
If fQuiet Then
sRetVal = oWShell.Run(sCmd, 0, True)
Else
sRetVal = oWShell.Run(sCmd, 2, True)
End if
Log " Return value: " & sRetVal
On Error Goto 0
End If
End Sub 'InvokeSignOutOfWAM
'-------------------------------------------------------------------------------
' ClearUsersRecursive
'
' Recursively clear from all local user profiles
'-------------------------------------------------------------------------------
Sub ClearUsersRecursive (sFolder)
Dim sValue
Dim oFolder, fld
Set oFolder = oFso.GetFolder(sFolder)
' exclude system protected link folders
If CBool(oFolder.Attributes AND 1024) Then Exit Sub
On Error Resume Next
For Each fld In oFolder.SubFolders
If Err <> 0 Then
Err.Clear
Else
ClearUsersRecursive fld.Path
End If
Next
End Sub 'ClearUsersRecursive
'-------------------------------------------------------------------------------
' ClearFolder
'
' clears/deletes the passed in folder
'-------------------------------------------------------------------------------
Sub ClearFolder(sDelFld)
Dim fld, attr
Dim sCmd
If oFso.FolderExists(sDelFld) Then
Set fld = oFso.GetFolder(sDelFld)
'ensure to remove read only flag
attr = fld.Attributes
If CBool(attr And 1) Then fld.Attributes = attr And (attr - 1)
'delete folder
fld.Delete True
Set fld = Nothing
'check if removal succeeded. If not try to RD
If oFso.FolderExists(sDelFld) Then
sCmd = "cmd.exe /c rd /s " & chr(34) & sDelFld & chr(34) & " /q"
Log "Remove folder: " & sDelFld
oWShell.Run sCmd, 0, True
End If
End If
End Sub
'-------------------------------------------------------------------------------
' ClearCredmanCache
'
' clear Office credentials from Windows Credentials Manager Cache
'-------------------------------------------------------------------------------
Sub ClearCredmanCache
Dim oExec, line, key
Dim sCmd, sRetVal, sCmdOut, sLine
Dim arrLines, dicRemoveCreds
Set dicRemoveCreds = CreateObject("Scripting.Dictionary")
dicRemoveCreds.Add "MicrosoftOffice1", "MicrosoftOffice1*"
dicRemoveCreds.Add "msteams", "msteams*"
dicRemoveCreds.Add "Microsoft_OC", "Microsoft_OC*"
dicRemoveCreds.Add "OneDrive Cached", "OneDrive*"
For Each key In dicRemoveCreds.Keys
sCmd = "cmdkey.exe /list:" & dicRemoveCreds.Item(key)
Set oExec = oWShell.Exec(sCmd)
sCmdOut = oExec.StdOut.ReadAll()
Do While oExec.Status = 0
WScript.Sleep 100
Loop
arrLines = Split(sCmdOut)
For Each line In arrLines
If (InStr(line, key) > 0 Or InStr(line, "OneDrive"))And Not InStr(line, dicRemoveCreds.Item(key)) > 0 Then
fBuildString = True
End If
If fBuildString And Len(line) < 1 Then
fBuildString = False
RunCmdkey sLine
End If
If fBuildString Then
sLine = sLine & " " & line
End If
Next
Next 'key
End Sub 'ClearCredmanCache
'-------------------------------------------------------------------------------
' RunCmdkey
'
' call CmdKey.exe to remove the credentials from CredMan
'-------------------------------------------------------------------------------
Sub RunCmdkey (sLine)
Dim sCmd, sRetVal
sLine = Replace(sLine, vbCrLf, "")
sLine = Replace(sLine, vbLf, "")
sLine = Trim(sLine)
sCmd = "cmdkey.exe /delete:" & Chr(34) & sLine & Chr(34)
Log "Remove from CredmanCache: " & sLine
Log "Execute removal command: " & sCmd
sRetVal = oWShell.Run(sCmd, 0, True)
Log sRetVal
sLine = ""
End Sub
'-------------------------------------------------------------------------------
' ResetUserKey
'
' attempts to delete the passed in key by direct delete and
' adds it to UserSetting scope to be reset on next application launch
'-------------------------------------------------------------------------------
Sub ResetUserKey(sRegKey, sCustomName)
Dim sSettingsKey, sCount, sRetVal, sCmd, sCUserKey, sSquirrelKey, sKey
Dim key
Dim iCount
Dim arrKey
If fClearO15 Then ResetUserKeyEx sRegKey, sCustomName, "15"
If fClearO16 Then ResetUserKeyEx sRegKey, sCustomName, "16"
End Sub 'ResetUserKey
'-------------------------------------------------------------------------------
' ResetUserKeyEx
'
' executes the version specific tasks for ResetUserKey
'-------------------------------------------------------------------------------
Sub ResetUserKeyEx(sRegKey, sCustomName, iVM)
Dim sSettingsKey, sCount, sRetVal, sCmd, sCUserKey, sSquirrelKey, sKey
Dim key
Dim iCount
Dim arrKey
If sCustomName = "" Then sCustomName = "CustomUserReset"
' attempt direct delete
sCUserKey = "HKCU\Software\Microsoft\Office\" & iVM & ".0\" & sRegKey
Log "Remove key " & sCUserKey
sCmd = "REG DELETE " & sCUserKey & " /f"
sRetVal = oWShell.Run(sCmd, 0, True)
'create user settings key to cover reset for other profiles
sSettingsKey = "SOFTWARE\Wow6432Node\Microsoft\Office\" & iVM & ".0\User Settings"
If (f64 And fO64) Or (Not f64) Then sSettingsKey = "SOFTWARE\Microsoft\Office\" & iVM & ".0\User Settings"
sSquirrelKey = sCustomName & "\Delete\Software\Microsoft\Office\" & iVM & ".0\" & sRegKey
arrKey = Split(sSquirrelKey, "\")
sKey = sSettingsKey
For Each key In arrKey
sKey = sKey & "\" & key
oReg.CreateKey HKLM, sKey
Next
iCount = 1
If Not fSafeForRoamingUsers Then
If RegReadDWordValue(HKLM, sSettingsKey & "\" & sCustomName, "Count", sCount) Then iCount = CInt(sCount) + 1
End If
oReg.SetDWordValue HKLM, sSettingsKey & "\" & sCustomName, "Count", iCount
oReg.SetDWordValue HKLM, sSettingsKey & "\" & sCustomName, "Order", 1
LogOnly "Add SettingsKey: HKLM\" & sKey
LogOnly "Count: " & iCount
End Sub 'ResetUserKeyEx
'-------------------------------------------------------------------------------
' CleanOSPP
'
' unpkeys the licenses from OSPP
'-------------------------------------------------------------------------------
Sub CleanOSPP (sFilter)
Dim pi
Dim oProductInstances
' Initialize the software protection platform object with a filter on Office 2013/2016 products
If GetVersionNT > 601 Then
Set oProductInstances = oWmiLocal.ExecQuery("SELECT ID, ApplicationId, PartialProductKey, Description, Name, ProductKeyID FROM SoftwareLicensingProduct WHERE ApplicationId = '" & OfficeAppId & "' " & "AND PartialProductKey <> NULL")
Else
Set oProductInstances = oWmiLocal.ExecQuery("SELECT ID, ApplicationId, PartialProductKey, Description, Name, ProductKeyID FROM OfficeSoftwareProtectionProduct WHERE ApplicationId = '" & OfficeAppId & "' " & "AND PartialProductKey <> NULL")
End If
' Remove all licenses
For Each pi in oProductInstances
Log "License: " & pi.Name
If NOT IsNull(pi) Then
If InStr(pi.Name, sFilter) > 0 Or sFilter = "" Then
Log "Uninstall ProductKey: " & pi.Name & " - Key: " & pi.ProductKeyID
pi.UninstallProductKey(pi.ProductKeyID)
End If
If UCase(sFilter) = "NOTO365" Then
If Not InStr(pi.Name, "O365") > 0 Then
Log "Uninstall ProductKey: " & pi.Name & " - Key: " & pi.ProductKeyID
pi.UninstallProductKey(pi.ProductKeyID)
End If
End If
End If
Next 'pi
End Sub 'CleanOSPP
'-------------------------------------------------------------------------------
' DetectOfficeBitness
'
' detect bitness of Office
'-------------------------------------------------------------------------------
Sub DetectOfficeBitness ()
Dim sOPlatform, sInstallRootPath
fO64 = False
If Not f64 Then Exit Sub
If RegReadStringValue(HKLM, "SOFTWARE\Microsoft\Office\ClickToRun\Configuration", "platform", sOPlatform) Then
fO64 = (sOPlatform = "x64")
Exit Sub
End If
If RegReadStringValue(HKLM, "SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration", "platform", sOPlatform) Then
fO64 = (sOPlatform = "x64")
Exit Sub
End If
If RegReadStringValue(HKLM, "SOFTWARE\Microsoft\Office\ClickToRun\propertyBag", "Platform", sOPlatform) Then
fO64 = (sOPlatform = "x64")
Exit Sub
End If
If RegReadStringValue(HKLM, "SOFTWARE\Microsoft\Office\15.0\ClickToRun\propertyBag", "Platform", sOPlatform) Then
fO64 = (sOPlatform = "x64")
Exit Sub
End If
If RegReadStringValue(HKLM, "SOFTWARE\Wow6432Node\Microsoft\Office\Common\InstallRoot", "Path", sInstallRootPath) Then
'fO64 = Not (InStr(sInstallRootPath, "(x86)") > 0)
fO64 = False
Exit Sub
End If
If RegReadStringValue(HKLM, "SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot", "Path", sInstallRootPath) Then
'fO64 = Not (InStr(sInstallRootPath, "(x86)") > 0)
fO64 = False
Exit Sub
End If
If RegReadStringValue(HKLM, "SOFTWARE\Microsoft\Office\Common\InstallRoot", "Path", sInstallRootPath) Then
'fO64 = Not (InStr(sInstallRootPath, "(x86)") > 0)
fO64 = True
Exit Sub
End If
If RegReadStringValue(HKLM, "SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot", "Path", sInstallRootPath) Then
'fO64 = Not (InStr(sInstallRootPath, "(x86)") > 0)
fO64 = True
Exit Sub
End If
End Sub 'DetectOfficeBitness
'-------------------------------------------------------------------------------
' DetectOSBitness
'
' detect bitness of the operating system
'-------------------------------------------------------------------------------
Sub DetectOSBitness ()
Dim ComputerItem, item
Set ComputerItem = oWmiLocal.ExecQuery("Select * from Win32_ComputerSystem")
For Each item In ComputerItem
f64 = Instr(Left(item.SystemType, 3), "64") > 0
Next
End Sub 'DetectOSBitness
'-------------------------------------------------------------------------------
' GetVersionNT
'
' Calculate the VerionNT number as integer
'-------------------------------------------------------------------------------
Function GetVersionNT ()
Dim sOsVersion
Dim arrVersion
Dim qOS
Dim oOsItem
Set qOS = oWmiLocal.ExecQuery( "Select * from Win32_OperatingSystem")
For Each oOsItem in qOS
sOsVersion = oOsItem.Version
Next
arrVersion = Split( sOsVersion, GetDelimiter( sOsVersion))
GetVersionNT = CInt( arrVersion( 0)) * 100 + CInt( arrVersion( 1))
End Function
'-------------------------------------------------------------------------------
' GetDelimiter
'
' Returns the delimiter in a version string
'-------------------------------------------------------------------------------
Function GetDelimiter (sVersion)
Dim iCnt, iAsc
GetDelimiter = " "
For iCnt = 1 To Len(sVersion)
iAsc = Asc(Mid(sVersion, iCnt, 1))
If Not (iASC >= 48 And iASC <= 57) Then
GetDelimiter = Mid(sVersion, iCnt, 1)
Exit Function
End If
Next 'iCnt
End Function
'-------------------------------------------------------------------------------
' RegReadDWordValue
'
' Check if a string value exists and return on zero if not
'-------------------------------------------------------------------------------
Function RegReadDWordValue(hDefKey, sSubKeyName, sName, sValue)
Dim RetVal
RetVal = oReg.GetDWORDValue(hDefKey, sSubKeyName, sName, sValue)
RegReadDWordValue = (RetVal = 0)
End Function 'RegReadDWordValue
'-------------------------------------------------------------------------------
' RegReadStringValue
'
' Check if a string value exists and return on zero if not
'-------------------------------------------------------------------------------
Function RegReadStringValue(hDefKey, sSubKeyName, sName, sValue)
Dim RetVal
RetVal = oReg.GetStringValue(hDefKey, sSubKeyName, sName, sValue)
RegReadStringValue = (RetVal = 0)
End Function 'RegReadSringValue
'-------------------------------------------------------------------------------
' RegReadExpStringValue
'
' Check if an expanded string value exists and return on zero if not
'-------------------------------------------------------------------------------
Function RegReadExpStringValue(hDefKey, sSubKeyName, sName, sValue)
Dim RetVal
RetVal = oReg.GetExpandedStringValue(hDefKey, sSubKeyName, sName, sValue)
RegReadStringValue = (RetVal = 0)
End Function 'RegReadSringValue
'-------------------------------------------------------------------------------
' RegEnumValues
'
' Enumerate a registry key to return all values
'-------------------------------------------------------------------------------
Function RegEnumValues(hDefKey, sSubKeyName, arrNames, arrTypes)
Dim RetVal
RetVal = oReg.EnumValues(hDefKey, sSubKeyName, arrNames, arrTypes)
RegEnumValues = (RetVal = 0) AND IsArray(arrNames) AND IsArray(arrTypes)
End Function 'RegEnumValues
'-------------------------------------------------------------------------------
' RelaunchAs64Host
'
' Relaunch self with 64 bit CScript host
'-------------------------------------------------------------------------------
Sub RelaunchAs64Host
Dim Argument, sCmd
Dim fQuietRelaunch
fQuietRelaunch = False
sCmd = Replace(LCase(wscript.Path), "syswow64", "sysnative") & "\cscript.exe " & Chr(34) & WScript.scriptFullName & Chr(34)
If fQuiet Then fQuietRelaunch = True
If Wscript.Arguments.Count > 0 Then
For Each Argument in Wscript.Arguments
sCmd = sCmd & " " & chr(34) & Argument & chr(34)
Select Case UCase(Argument)
Case "/Q", "/QUIET"
fQuietRelaunch = True
End Select
Next 'Argument
End If
sCmd = sCmd & " /ChangedHostBitness"
If fQuietRelaunch Then
sCmd = Replace (sCmd, "\cscript.exe", "\wscript.exe")
Wscript.Quit CLng(oWShell.Run (sCmd, 0, True))
Else
Wscript.Quit CLng(oWShell.Run (sCmd, 1, True))
End If
End Sub 'RelaunchAs64Host
'-------------------------------------------------------------------------------
' CreateLog
'
' Create the removal log file
'-------------------------------------------------------------------------------
Sub CreateLog
Dim DateTime
Dim sLogName
On Error Resume Next
' create the log file
Set DateTime = CreateObject("WbemScripting.SWbemDateTime")
DateTime.SetVarDate Now, True
If sLogDir = "" Then sLogDir = sTemp
sLogName = sLogDir & "\" & oWShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
sLogName = sLogName & "_" & Left(DateTime.Value, 14)
sLogName = sLogName & "_OLicenseClean.txt"
Err.Clear
Set LogStream = oFso.CreateTextFile(sLogName, True, True)
If Err <> 0 Then
Err.Clear
sLogDir = sTemp
sLogName = sLogDir & "\" & oWShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
sLogName = sLogName & "_" & Left(DateTime.Value, 14)
sLogName = sLogName & "_oLicenseClean.txt"
Set LogStream = oFso.CreateTextFile(sLogName, True, True)
End If
On Error Goto 0
LogH2 "Microsoft Customer Support Services - Office License Reset Utility" & vbCrLf & vbCrLf & _
"Version: " & vbTab & SCRIPTVERSION & vbCrLf & _
"64 bit OS: " & vbTab & f64 & vbCrLf & _
"64 bit Office: " & vbTab & fO64 & vbCrLf & _
"Cleanup start: " & vbTab & Time
LogH2 "OS Details: " & sOSinfo & vbCrLf
End Sub 'CreateLog
'-------------------------------------------------------------------------------
' LogH
'
' Write a header log string to the log file
'-------------------------------------------------------------------------------
Sub LogH (sLog)
LogStream.WriteLine ""
sLog = sLog & vbCrLf & String(Len(sLog), "=")
If NOT fQuiet AND fCScript Then wscript.echo ""
If NOT fQuiet AND fCScript Then wscript.echo sLog
LogStream.WriteLine sLog
End Sub 'Logh
'-------------------------------------------------------------------------------
' LogH1
'
' Write a header log string to the log file
'-------------------------------------------------------------------------------
Sub LogH1 (sLog)
LogStream.WriteLine ""
sLog = sLog & vbCrLf & String(Len(sLog), "-")
If NOT fQuiet AND fCScript Then wscript.echo ""
If NOT fQuiet AND fCScript Then wscript.echo sLog
LogStream.WriteLine sLog
End Sub 'LogH1
'-------------------------------------------------------------------------------
' LogH2
'
' Write w/o indent Cmd window and the log file
'-------------------------------------------------------------------------------
Sub LogH2 (sLog)
If NOT fQuiet AND fCScript Then wscript.echo sLog
LogStream.WriteLine ""
LogStream.WriteLine sLog
End Sub 'LogH2
'-------------------------------------------------------------------------------
' Log
'
' Echos the log string to the Cmd window and the log file
'-------------------------------------------------------------------------------
Sub Log (sLog)
If NOT fQuiet AND fCScript Then wscript.echo sLog
If sLog = "" Then
LogStream.WriteLine
Else
LogStream.WriteLine " " & Time & ": " & sLog
End If
End Sub 'Log
'-------------------------------------------------------------------------------
' LogOnly
'
' Commits the log string to the log file
'-------------------------------------------------------------------------------
Sub LogOnly (sLog)
If sLog = "" Then
LogStream.WriteLine
Else
LogStream.WriteLine " " & Time & ": " & sLog
End If
End Sub 'Log

BIN
OfficeScrubber/bin/OffScrub03.vbs

Binary file not shown.

BIN
OfficeScrubber/bin/OffScrub07.vbs

Binary file not shown.

BIN
OfficeScrubber/bin/OffScrub10.vbs

Binary file not shown.

BIN
OfficeScrubber/bin/OffScrubC2R.vbs

Binary file not shown.

BIN
OfficeScrubber/bin/OffScrub_O15msi.vbs

Binary file not shown.

BIN
OfficeScrubber/bin/OffScrub_O16msi.vbs

Binary file not shown.

27
OfficeScrubber/bin/WAMAccounts.ps1

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
if(-not [Windows.Foundation.Metadata.ApiInformation,Windows,ContentType=WindowsRuntime]::IsMethodPresent("Windows.Security.Authentication.Web.Core.WebAuthenticationCoreManager", "FindAllAccountsAsync"))
{
throw "This script is not supported on this Windows version. Please, use CleanupWPJ.cmd."
}
Add-Type -AssemblyName System.Runtime.WindowsRuntime
Function AwaitAction($WinRtAction) {
$asTask = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and !$_.IsGenericMethod })[0]
$netTask = $asTask.Invoke($null, @($WinRtAction))
$netTask.Wait(-1) | Out-Null
}
Function Await($WinRtTask, $ResultType) {
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
}
$provider = Await ([Windows.Security.Authentication.Web.Core.WebAuthenticationCoreManager,Windows,ContentType=WindowsRuntime]::FindAccountProviderAsync("https://login.microsoft.com", "organizations")) ([Windows.Security.Credentials.WebAccountProvider,Windows,ContentType=WindowsRuntime])
$accounts = Await ([Windows.Security.Authentication.Web.Core.WebAuthenticationCoreManager,Windows,ContentType=WindowsRuntime]::FindAllAccountsAsync($provider, "d3590ed6-52b3-4102-aeff-aad2292ab01c")) ([Windows.Security.Authentication.Web.Core.FindAllAccountsResult,Windows,ContentType=WindowsRuntime])
$accounts.Accounts | % { AwaitAction ($_.SignOutAsync(d3590ed6-52b3-4102-aeff-aad2292ab01c)) }

62
W10MUI/Updates/W10UI.cmd

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
@setlocal DisableDelayedExpansion
@set uiv=v10.24
@set uiv=v10.25
@echo off
:: enable debug mode, you must also set target and repo (if updates are not beside the script)
set _Debug=0
@ -33,7 +33,7 @@ set ResetBase=0 @@ -33,7 +33,7 @@ set ResetBase=0
:: update winre.wim if detected inside install.wim
set WinRE=1
:: Force updating winre.wim with Cumulative Update even if SafeOS update detected
:: Force updating winre.wim with Cumulative Update regardless if SafeOS update detected
set LCUwinre=0
:: update ISO boot files bootmgr/bootmgr.efi/efisys.bin from Cumulative Update
@ -744,18 +744,24 @@ rmdir /s /q "%dest%\" %_Nul3% @@ -744,18 +744,24 @@ rmdir /s /q "%dest%\" %_Nul3%
rmdir /s /q "checker\" %_Nul3%
goto :eof
)
set _extsafe=0
set "_type="
if %_build% geq 17763 findstr /i /m "WinPE" "checker\update.mum" %_Nul3% && (
%_Nul3% findstr /i /m "Edition\"" "checker\update.mum"
if errorlevel 1 set "_type=[WinPE]"
if errorlevel 1 (set "_type=[WinPE]"&set _extsafe=1)
)
if not defined _type (
if not defined _type set _extsafe=1
if %_extsafe%==1 (
expand.exe -f:*_microsoft-windows-sysreset_*.manifest "!repo!\!package!" "checker" %_Null%
if exist "checker\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[WinPE]"
if exist "checker\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[SafeOS DU]"
)
if not defined _type (
if %_extsafe%==1 if not exist "checker\*_microsoft-windows-sysreset_*.manifest" (
expand.exe -f:*_microsoft-windows-winre-tools_*.manifest "!repo!\!package!" "checker" %_Null%
if exist "checker\*_microsoft-windows-winre-tools_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[SafeOS DU]"
)
if %_extsafe%==1 if not exist "checker\*_microsoft-windows-sysreset_*.manifest" (
expand.exe -f:*_microsoft-windows-i..dsetup-rejuvenation_*.manifest "!repo!\!package!" "checker" %_Null%
if exist "checker\*_microsoft-windows-i..dsetup-rejuvenation_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[WinPE]"
if exist "checker\*_microsoft-windows-i..dsetup-rejuvenation_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[SafeOS DU]"
)
if not defined _type (
findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% && set "_type=[LCU]"
@ -992,6 +998,8 @@ if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-EnterpriseS*E @@ -992,6 +998,8 @@ if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-EnterpriseS*E
if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-IoTEnterpriseS*Edition~*.mum" set LTSC=1
if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" set LTSC=1
if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-Server*ACorEdition~*.mum" set LTSC=0
if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-Server*NanoEdition~*.mum" set LTSC=0
if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-ServerAzureStackHCI*Edition~*.mum" set LTSC=0
)
if exist "!repo!\*Windows1*-KB*%arch%*.cab" (for /f "tokens=* delims=" %%# in ('dir /b /on "!repo!\*Windows1*-KB*%arch%*.cab"') do (call set /a _sum+=1))
if %_build% geq 21382 if exist "!repo!\*Windows1*-KB*%arch%*.msu" (for /f "tokens=* delims=" %%# in ('dir /b /on "!repo!\*Windows1*-KB*%arch%*.msu"') do if defined msu_%%~n# (call set /a _sum+=1))
@ -1015,7 +1023,7 @@ reg.exe save HKLM\%SOFTWARE% "!mumtarget!\Windows\System32\Config\SOFTWARE2" %_N @@ -1015,7 +1023,7 @@ reg.exe save HKLM\%SOFTWARE% "!mumtarget!\Windows\System32\Config\SOFTWARE2" %_N
reg.exe unload HKLM\%SOFTWARE% %_Nul1%
move /y "!mumtarget!\Windows\System32\Config\SOFTWARE2" "!mumtarget!\Windows\System32\Config\SOFTWARE" %_Nul1%
)
if %online%==0 if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if %online%==0 if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" if /i not %arch%==arm64 (
reg.exe load HKLM\%SOFTWARE% "!mumtarget!\Windows\System32\Config\SOFTWARE" %_Nul1%
reg.exe add HKLM\%SOFTWARE%\%_sbs% /v DisableComponentBackups /t REG_DWORD /d 1 /f %_Nul1%
reg.exe unload HKLM\%SOFTWARE% %_Nul1%
@ -1091,17 +1099,15 @@ for %%# in (%dupdt%) do (set "dest=%%~n#"&call :pXML) @@ -1091,17 +1099,15 @@ for %%# in (%dupdt%) do (set "dest=%%~n#"&call :pXML)
set dowinre=0
set doboot=0
set doinstall=0
if defined cumulative if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" if %_build% neq 14393 (
if %verb%==0 if not defined safeos set dowinre=1
if %verb%==0 if defined safeos if %LCUwinre%==1 set dowinre=1
if %verb%==1 set doboot=1
if defined cumulative if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if %verb%==0 if %LCUwinre%==1 set dowinre=1
if %verb%==1 if %_build% neq 14393 set doboot=1
)
if defined cumulative if not exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if %verb%==1 set doinstall=1
)
if defined lcumsu if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if %verb%==0 if not defined safeos set dowinre=1
if %verb%==0 if defined safeos if %LCUwinre%==1 set dowinre=1
if %verb%==0 if %LCUwinre%==1 set dowinre=1
if %verb%==1 set doboot=1
)
if defined lcumsu if not exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
@ -1125,7 +1131,7 @@ echo.&echo %%# @@ -1125,7 +1131,7 @@ echo.&echo %%#
)
if !errorlevel! equ 1726 %_dism2%:"!_cabdir!" %dismtarget% /Get-Packages %_Nul1%
:cuinstall
if %doinstall%==0 goto :cumwd
if %doinstall%==0 goto :cuwd
set callclean=1
if defined cumulative %_dism2%:"!_cabdir!" %dismtarget% /LogPath:"%_dLog%\DismLCU.log" /Add-Package %cumulative%
if defined lcumsu for %%# in (%lcumsu%) do (
@ -1134,8 +1140,8 @@ echo.&echo %%# @@ -1134,8 +1140,8 @@ echo.&echo %%#
)
if !errorlevel! equ 1726 %_dism2%:"!_cabdir!" %dismtarget% /Get-Packages %_Nul1%
if %_build% equ 14393 if %wimfiles% equ 1 call :MeltdownSpectre
if not exist "!mumtarget!\Windows\Servicing\Packages\Package_for_RollupFix*.mum" goto :cumwd
if %online%==1 goto :cumwd
if not exist "!mumtarget!\Windows\Servicing\Packages\Package_for_RollupFix*.mum" goto :cuwd
if %online%==1 goto :cuwd
for /f %%# in ('dir /b /a:-d /od "!mumtarget!\Windows\Servicing\Packages\Package_for_RollupFix*.mum"') do set "lcumum=%%#"
if defined lcumsu if %_build% geq 22621 if exist "!_cabdir!\LCU.mum" (
%_Nul3% icacls "!mumtarget!\Windows\Servicing\Packages\%lcumum%" /save "!_cabdir!\acl.txt"
@ -1146,7 +1152,7 @@ if defined lcumsu if %_build% geq 22621 if exist "!_cabdir!\LCU.mum" ( @@ -1146,7 +1152,7 @@ if defined lcumsu if %_build% geq 22621 if exist "!_cabdir!\LCU.mum" (
%_Nul3% icacls "!mumtarget!\Windows\Servicing\Packages" /restore "!_cabdir!\acl.txt"
%_Nul3% del /f /q "!_cabdir!\acl.txt"
)
:cumwd
:cuwd
if defined lcupkg call :ReLCU
if defined callclean call :cleanup
if defined mpamfe (
@ -1305,17 +1311,25 @@ goto :eof @@ -1305,17 +1311,25 @@ goto :eof
)
if exist "%dest%\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
if not exist "!mumtarget!\Windows\Servicing\Packages\WinPE-SRT-Package~*.mum" (set /a _sum-=1&goto :eof)
if %verb%==1 (set /a _sum-=1&goto :eof)
set "safeos=!safeos! /PackagePath:%dest%\update.mum"
goto :eof
)
if exist "%dest%\*_microsoft-windows-i..dsetup-rejuvenation_*.manifest" if not exist "%dest%\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
if exist "%dest%\*_microsoft-windows-winre-tools_*.manifest" if not exist "%dest%\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
if not exist "!mumtarget!\Windows\Servicing\Packages\WinPE-SRT-Package~*.mum" (set /a _sum-=1&goto :eof)
if %verb%==1 (set /a _sum-=1&goto :eof)
set "safeos=!safeos! /PackagePath:%dest%\update.mum"
goto :eof
)
if exist "%dest%\*_microsoft-windows-i..dsetup-rejuvenation_*.manifest" if not exist "%dest%\*_microsoft-windows-sysreset_*.manifest" if not exist "%dest%\*_microsoft-windows-winre-tools_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
if not exist "!mumtarget!\Windows\Servicing\Packages\WinPE-Rejuv-Package~*.mum" (set /a _sum-=1&goto :eof)
if %verb%==1 (set /a _sum-=1&goto :eof)
set "safeos=!safeos! /PackagePath:%dest%\update.mum"
goto :eof
)
if exist "%dest%\*_microsoft-windows-s..boot-firmwareupdate_*.manifest" (
if %winbuild% lss 9600 (set /a _sum-=1&goto :eof)
if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (set /a _sum-=1&goto :eof)
if %winbuild% lss 9600 (set /a _sum-=1&goto :eof)
set secureboot=!secureboot! /PackagePath:"!repo!\!package!"
goto :eof
)
@ -1331,9 +1345,10 @@ if %_build% geq 16299 ( @@ -1331,9 +1345,10 @@ if %_build% geq 16299 (
if "!flash!"=="0" (set /a _sum-=1&goto :eof)
)
)
if exist "%dest%\*enablement-package*.mum" if not exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if exist "%dest%\*enablement-package*.mum" (
set epkb=0
for /f "tokens=3 delims== " %%# in ('findstr /i "Edition" "%dest%\update.mum" %_Nul6%') do if exist "!mumtarget!\Windows\Servicing\packages\%%~#*.mum" set epkb=1
if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" if %verb%==1 findstr /i /m "WinPE" "%dest%\update.mum" %_Nul3% && set epkb=1
if "!epkb!"=="0" (set /a _sum-=1&goto :eof)
)
for %%# in (%directcab%) do (
@ -1369,7 +1384,10 @@ if exist "%dest%\*_%_EsuCmp%_*.manifest" if exist "%dest%\*_%_CedCmp%_*.manifest @@ -1369,7 +1384,10 @@ if exist "%dest%\*_%_EsuCmp%_*.manifest" if exist "%dest%\*_%_CedCmp%_*.manifest
set "cumulative=!cumulative! /PackagePath:%dest%\update.mum"
goto :eof
)
if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (set "ldr=!ldr! /PackagePath:%dest%\update.mum"&goto :eof)
if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if %verb%==1 set "ldr=!ldr! /PackagePath:%dest%\update.mum"
goto :eof
)
if exist "%dest%\*_%_EsuCmp%_*.manifest" if %LTSC% equ 0 (set "supdt=!supdt! !package!"&goto :eof)
if exist "%dest%\*_%_CedCmp%_*.manifest" if %SkipEdge% equ 1 (set "cupdt=!cupdt! !package!"&goto :eof)
if exist "%dest%\*_%_CedCmp%_*.manifest" if %SkipEdge% equ 2 call :deEdge

7
W10UI/README.md

@ -190,6 +190,13 @@ the option will also auto exit at the end without prompt @@ -190,6 +190,13 @@ the option will also auto exit at the end without prompt
<details><summary>changelog</summary>
10.25:
- Changed integration routine for WinPE images:
winre.wim will get SSU + SafeOS only
winre.wim will get LCU only if LCUwinre=1 (regardless of SafeOS)
boot.wim will not get SafeOS DU (regardless of LCU)
boot.wim will get Enablement KB
10.24:
- Add support for future Windows 11 22H2 Moments Enablement Packages

62
W10UI/W10UI.cmd

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
@setlocal DisableDelayedExpansion
@set uiv=v10.24
@set uiv=v10.25
@echo off
:: enable debug mode, you must also set target and repo (if updates are not beside the script)
set _Debug=0
@ -33,7 +33,7 @@ set ResetBase=0 @@ -33,7 +33,7 @@ set ResetBase=0
:: update winre.wim if detected inside install.wim
set WinRE=1
:: Force updating winre.wim with Cumulative Update even if SafeOS update detected
:: Force updating winre.wim with Cumulative Update regardless if SafeOS update detected
set LCUwinre=0
:: update ISO boot files bootmgr/bootmgr.efi/efisys.bin from Cumulative Update
@ -744,18 +744,24 @@ rmdir /s /q "%dest%\" %_Nul3% @@ -744,18 +744,24 @@ rmdir /s /q "%dest%\" %_Nul3%
rmdir /s /q "checker\" %_Nul3%
goto :eof
)
set _extsafe=0
set "_type="
if %_build% geq 17763 findstr /i /m "WinPE" "checker\update.mum" %_Nul3% && (
%_Nul3% findstr /i /m "Edition\"" "checker\update.mum"
if errorlevel 1 set "_type=[WinPE]"
if errorlevel 1 (set "_type=[WinPE]"&set _extsafe=1)
)
if not defined _type (
if not defined _type set _extsafe=1
if %_extsafe%==1 (
expand.exe -f:*_microsoft-windows-sysreset_*.manifest "!repo!\!package!" "checker" %_Null%
if exist "checker\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[WinPE]"
if exist "checker\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[SafeOS DU]"
)
if not defined _type (
if %_extsafe%==1 if not exist "checker\*_microsoft-windows-sysreset_*.manifest" (
expand.exe -f:*_microsoft-windows-winre-tools_*.manifest "!repo!\!package!" "checker" %_Null%
if exist "checker\*_microsoft-windows-winre-tools_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[SafeOS DU]"
)
if %_extsafe%==1 if not exist "checker\*_microsoft-windows-sysreset_*.manifest" (
expand.exe -f:*_microsoft-windows-i..dsetup-rejuvenation_*.manifest "!repo!\!package!" "checker" %_Null%
if exist "checker\*_microsoft-windows-i..dsetup-rejuvenation_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[WinPE]"
if exist "checker\*_microsoft-windows-i..dsetup-rejuvenation_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[SafeOS DU]"
)
if not defined _type (
findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% && set "_type=[LCU]"
@ -992,6 +998,8 @@ if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-EnterpriseS*E @@ -992,6 +998,8 @@ if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-EnterpriseS*E
if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-IoTEnterpriseS*Edition~*.mum" set LTSC=1
if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" set LTSC=1
if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-Server*ACorEdition~*.mum" set LTSC=0
if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-Server*NanoEdition~*.mum" set LTSC=0
if exist "!mumtarget!\Windows\Servicing\Packages\Microsoft-Windows-ServerAzureStackHCI*Edition~*.mum" set LTSC=0
)
if exist "!repo!\*Windows1*-KB*%arch%*.cab" (for /f "tokens=* delims=" %%# in ('dir /b /on "!repo!\*Windows1*-KB*%arch%*.cab"') do (call set /a _sum+=1))
if %_build% geq 21382 if exist "!repo!\*Windows1*-KB*%arch%*.msu" (for /f "tokens=* delims=" %%# in ('dir /b /on "!repo!\*Windows1*-KB*%arch%*.msu"') do if defined msu_%%~n# (call set /a _sum+=1))
@ -1015,7 +1023,7 @@ reg.exe save HKLM\%SOFTWARE% "!mumtarget!\Windows\System32\Config\SOFTWARE2" %_N @@ -1015,7 +1023,7 @@ reg.exe save HKLM\%SOFTWARE% "!mumtarget!\Windows\System32\Config\SOFTWARE2" %_N
reg.exe unload HKLM\%SOFTWARE% %_Nul1%
move /y "!mumtarget!\Windows\System32\Config\SOFTWARE2" "!mumtarget!\Windows\System32\Config\SOFTWARE" %_Nul1%
)
if %online%==0 if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if %online%==0 if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" if /i not %arch%==arm64 (
reg.exe load HKLM\%SOFTWARE% "!mumtarget!\Windows\System32\Config\SOFTWARE" %_Nul1%
reg.exe add HKLM\%SOFTWARE%\%_sbs% /v DisableComponentBackups /t REG_DWORD /d 1 /f %_Nul1%
reg.exe unload HKLM\%SOFTWARE% %_Nul1%
@ -1091,17 +1099,15 @@ for %%# in (%dupdt%) do (set "dest=%%~n#"&call :pXML) @@ -1091,17 +1099,15 @@ for %%# in (%dupdt%) do (set "dest=%%~n#"&call :pXML)
set dowinre=0
set doboot=0
set doinstall=0
if defined cumulative if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" if %_build% neq 14393 (
if %verb%==0 if not defined safeos set dowinre=1
if %verb%==0 if defined safeos if %LCUwinre%==1 set dowinre=1
if %verb%==1 set doboot=1
if defined cumulative if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if %verb%==0 if %LCUwinre%==1 set dowinre=1
if %verb%==1 if %_build% neq 14393 set doboot=1
)
if defined cumulative if not exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if %verb%==1 set doinstall=1
)
if defined lcumsu if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if %verb%==0 if not defined safeos set dowinre=1
if %verb%==0 if defined safeos if %LCUwinre%==1 set dowinre=1
if %verb%==0 if %LCUwinre%==1 set dowinre=1
if %verb%==1 set doboot=1
)
if defined lcumsu if not exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
@ -1125,7 +1131,7 @@ echo.&echo %%# @@ -1125,7 +1131,7 @@ echo.&echo %%#
)
if !errorlevel! equ 1726 %_dism2%:"!_cabdir!" %dismtarget% /Get-Packages %_Nul1%
:cuinstall
if %doinstall%==0 goto :cumwd
if %doinstall%==0 goto :cuwd
set callclean=1
if defined cumulative %_dism2%:"!_cabdir!" %dismtarget% /LogPath:"%_dLog%\DismLCU.log" /Add-Package %cumulative%
if defined lcumsu for %%# in (%lcumsu%) do (
@ -1134,8 +1140,8 @@ echo.&echo %%# @@ -1134,8 +1140,8 @@ echo.&echo %%#
)
if !errorlevel! equ 1726 %_dism2%:"!_cabdir!" %dismtarget% /Get-Packages %_Nul1%
if %_build% equ 14393 if %wimfiles% equ 1 call :MeltdownSpectre
if not exist "!mumtarget!\Windows\Servicing\Packages\Package_for_RollupFix*.mum" goto :cumwd
if %online%==1 goto :cumwd
if not exist "!mumtarget!\Windows\Servicing\Packages\Package_for_RollupFix*.mum" goto :cuwd
if %online%==1 goto :cuwd
for /f %%# in ('dir /b /a:-d /od "!mumtarget!\Windows\Servicing\Packages\Package_for_RollupFix*.mum"') do set "lcumum=%%#"
if defined lcumsu if %_build% geq 22621 if exist "!_cabdir!\LCU.mum" (
%_Nul3% icacls "!mumtarget!\Windows\Servicing\Packages\%lcumum%" /save "!_cabdir!\acl.txt"
@ -1146,7 +1152,7 @@ if defined lcumsu if %_build% geq 22621 if exist "!_cabdir!\LCU.mum" ( @@ -1146,7 +1152,7 @@ if defined lcumsu if %_build% geq 22621 if exist "!_cabdir!\LCU.mum" (
%_Nul3% icacls "!mumtarget!\Windows\Servicing\Packages" /restore "!_cabdir!\acl.txt"
%_Nul3% del /f /q "!_cabdir!\acl.txt"
)
:cumwd
:cuwd
if defined lcupkg call :ReLCU
if defined callclean call :cleanup
if defined mpamfe (
@ -1305,17 +1311,25 @@ goto :eof @@ -1305,17 +1311,25 @@ goto :eof
)
if exist "%dest%\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
if not exist "!mumtarget!\Windows\Servicing\Packages\WinPE-SRT-Package~*.mum" (set /a _sum-=1&goto :eof)
if %verb%==1 (set /a _sum-=1&goto :eof)
set "safeos=!safeos! /PackagePath:%dest%\update.mum"
goto :eof
)
if exist "%dest%\*_microsoft-windows-i..dsetup-rejuvenation_*.manifest" if not exist "%dest%\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
if exist "%dest%\*_microsoft-windows-winre-tools_*.manifest" if not exist "%dest%\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
if not exist "!mumtarget!\Windows\Servicing\Packages\WinPE-SRT-Package~*.mum" (set /a _sum-=1&goto :eof)
if %verb%==1 (set /a _sum-=1&goto :eof)
set "safeos=!safeos! /PackagePath:%dest%\update.mum"
goto :eof
)
if exist "%dest%\*_microsoft-windows-i..dsetup-rejuvenation_*.manifest" if not exist "%dest%\*_microsoft-windows-sysreset_*.manifest" if not exist "%dest%\*_microsoft-windows-winre-tools_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
if not exist "!mumtarget!\Windows\Servicing\Packages\WinPE-Rejuv-Package~*.mum" (set /a _sum-=1&goto :eof)
if %verb%==1 (set /a _sum-=1&goto :eof)
set "safeos=!safeos! /PackagePath:%dest%\update.mum"
goto :eof
)
if exist "%dest%\*_microsoft-windows-s..boot-firmwareupdate_*.manifest" (
if %winbuild% lss 9600 (set /a _sum-=1&goto :eof)
if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (set /a _sum-=1&goto :eof)
if %winbuild% lss 9600 (set /a _sum-=1&goto :eof)
set secureboot=!secureboot! /PackagePath:"!repo!\!package!"
goto :eof
)
@ -1331,9 +1345,10 @@ if %_build% geq 16299 ( @@ -1331,9 +1345,10 @@ if %_build% geq 16299 (
if "!flash!"=="0" (set /a _sum-=1&goto :eof)
)
)
if exist "%dest%\*enablement-package*.mum" if not exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if exist "%dest%\*enablement-package*.mum" (
set epkb=0
for /f "tokens=3 delims== " %%# in ('findstr /i "Edition" "%dest%\update.mum" %_Nul6%') do if exist "!mumtarget!\Windows\Servicing\packages\%%~#*.mum" set epkb=1
if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" if %verb%==1 findstr /i /m "WinPE" "%dest%\update.mum" %_Nul3% && set epkb=1
if "!epkb!"=="0" (set /a _sum-=1&goto :eof)
)
for %%# in (%directcab%) do (
@ -1369,7 +1384,10 @@ if exist "%dest%\*_%_EsuCmp%_*.manifest" if exist "%dest%\*_%_CedCmp%_*.manifest @@ -1369,7 +1384,10 @@ if exist "%dest%\*_%_EsuCmp%_*.manifest" if exist "%dest%\*_%_CedCmp%_*.manifest
set "cumulative=!cumulative! /PackagePath:%dest%\update.mum"
goto :eof
)
if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (set "ldr=!ldr! /PackagePath:%dest%\update.mum"&goto :eof)
if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
if %verb%==1 set "ldr=!ldr! /PackagePath:%dest%\update.mum"
goto :eof
)
if exist "%dest%\*_%_EsuCmp%_*.manifest" if %LTSC% equ 0 (set "supdt=!supdt! !package!"&goto :eof)
if exist "%dest%\*_%_CedCmp%_*.manifest" if %SkipEdge% equ 1 (set "cupdt=!cupdt! !package!"&goto :eof)
if exist "%dest%\*_%_CedCmp%_*.manifest" if %SkipEdge% equ 2 call :deEdge

2
esd-decrypter-wimlib/decrypt.cmd

@ -712,9 +712,11 @@ if %revver%==22000.258 (set _label=22000.258.211007-1642.co_%_rsr%&set branch=co @@ -712,9 +712,11 @@ if %revver%==22000.258 (set _label=22000.258.211007-1642.co_%_rsr%&set branch=co
if %revver%==22000.194 (set _label=22000.194.210913-1444.co_%_rsr%&set branch=co_%_rsr%&set ISOnameESD=0)
if %revver%==22000.132 (set _label=22000.132.210809-2349.co_%_rsr%&set branch=co_%_rsr%&set ISOnameESD=0)
if %revmaj%==19045 (set _label=%revver%.%_time%.22h2_%_rsr%&set branch=22h2_%_rsr%)
if %revver%==19045.2006 (set _label=19045.2006.220908-0225.22h2_%_rsr%&set branch=22h2_%_rsr%&set ISOnameESD=0)
if %revver%==19045.1826 (set _label=19045.1826.220707-2303.22h2_%_rsr%&set branch=22h2_%_rsr%&set ISOnameESD=0)
if %revmaj%==19044 (set _label=%revver%.%_time%.21h2_%_rsr%&set branch=21h2_%_rsr%)
if %revver%==19044.1706 (set _label=19044.1706.220505-0136.21h2_%_rsr%&set branch=21h2_%_rsr%&set ISOnameESD=0)
if %revver%==19044.1586 (set _label=19044.1586.220303-0721.21h2_%_rsr%&set branch=21h2_%_rsr%&set ISOnameESD=0)
if %revver%==19044.1288 (set _label=19044.1288.211006-0501.21h2_%_rsr%&set branch=21h2_%_rsr%&set ISOnameESD=0)
if %revver%==19044.1165 (set _label=19044.1165.210806-1742.21h2_%_rsr%&set branch=21h2_%_rsr%&set ISOnameESD=0)
if %revmaj%==19043 (set _label=%revver%.%_time%.21h1_%_rsr%&set branch=21h1_%_rsr%)

Loading…
Cancel
Save