FOR/F"TOKENS=2 DELIMS=="%%A IN('"WMIC PATH SoftwareLicensingProduct WHERE (Name LIKE 'Windows%%' AND PartialProductKey is not NULL) GET LicenseFamily /VALUE" %_Nul6%')DOIFNOTERRORLEVEL1SET"EditionWMI=%%A"
FOR/F"TOKENS=2 DELIMS=="%%A IN('"WMIC PATH SoftwareLicensingProduct WHERE (ApplicationId='%_wApp%' AND PartialProductKey is not NULL) GET LicenseFamily /VALUE" %_Nul6%')DOIFNOTERRORLEVEL1SET"EditionWMI=%%A"
wmic path %spp% where (Description like '%%KMSCLIENT%%') get Name %_Nul2%| findstr /i Windows %_Nul1%&&(setWinVL=1)||(echo.&echoWindows %EditionID% edition does not support KMS activation...)
wmic path %spp% where (Description like '%%KMSCLIENT%%') get Name %_Nul2%| findstr /i Windows %_Nul1%&&(setWinVL=1)||(echo.&echo%_winos% does not support KMS activation...)
wmic path %spp% where (Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL) get Name %_Nul2%| findstr /i Windows %_Nul1%&&(setgvlk=1)||(setgvlk=0)
wmic path %spp% where (Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL) get Name %_Nul2%| findstr /i Windows %_Nul1%&&(set_gvlk=1)||(set_gvlk=0)
setgpr=0
if%winbuild%GEQ 10240 if%SkipKMS38%NEQ 0 if%gvlk%EQU 1 for/f"tokens=2 delims=="%%A in('"wmic path %spp% where (Description like '%%KMSCLIENT%%' and Name like 'Windows%%' and PartialProductKey is not NULL) get GracePeriodRemaining /VALUE" %_Nul6%')doset"gpr=%%A"
if%winbuild%GEQ 10240 if%SkipKMS38%NEQ 0 if%_gvlk%EQU 1 for/f"tokens=2 delims=="%%A in('"wmic path %spp% where (ApplicationId='%_wApp%' and Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL) get GracePeriodRemaining /VALUE" %_Nul6%')doset"gpr=%%A"
if%gpr%NEQ 0 if%gpr%GTR 259200 (
setW1nd0ws=0
wmic path %spp% where "Description like '%%KMSCLIENT%%' and Name like 'Windows%%' and PartialProductKey is not NULL" get LicenseFamily %_Nul2%| findstr /i EnterpriseG %_Nul1%&&(callsetW1nd0ws=1)
wmic path %spp% where "ApplicationId='%_wApp%' and Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL" get LicenseFamily %_Nul2%| findstr /i EnterpriseG %_Nul1%&&(callsetW1nd0ws=1)
)
for/f"tokens=2 delims=="%%A in('"wmic path %sps% get Version /VALUE"')dosetver=%%A
wmic path %sps% where version='%ver%' call SetKeyManagementServiceMachine MachineName="%KMS_IP%"%_Nul3%
wmic path %sps% where version='%ver%' call SetKeyManagementServicePort %KMS_Port%%_Nul3%
if%W1nd0ws%EQU 0 for/f"tokens=2 delims=="%%G in('"wmic path %spp% where (Description like '%%KMSCLIENT%%' and Name like 'Windows%%') get ID /VALUE"') do (set app=%%G&call :sppchkwin)
if%W1nd0ws%EQU 1 if%ActWindows%NEQ 0 for/f"tokens=2 delims=="%%G in('"wmic path %spp% where (Description like '%%KMSCLIENT%%' and Name like 'Windows%%') get ID /VALUE"') do (set app=%%G&call :sppchkwin)
if%W1nd0ws%EQU 0 for/f"tokens=2 delims=="%%G in('"wmic path %spp% where (ApplicationId='%_wApp%' and Description like '%%KMSCLIENT%%') get ID /VALUE"') do (set app=%%G&call :sppchkwin)
if%W1nd0ws%EQU 1 if%ActWindows%NEQ 0 for/f"tokens=2 delims=="%%G in('"wmic path %spp% where (ApplicationId='%_wApp%' and Description like '%%KMSCLIENT%%') get ID /VALUE"') do (set app=%%G&call :sppchkwin)
if%W1nd0ws%EQU 1 if%ActWindows%EQU 0 (echo.&echo Windows activation is OFF...)
if%Off1ce%EQU 1 if%ActOffice%NEQ 0 for/f"tokens=2 delims=="%%G in('"wmic path %spp% where (Description like '%%KMSCLIENT%%' and Name like 'Office%%') get ID /VALUE"') do (set app=%%G&call :sppchkoff)
if%Off1ce%EQU 1 if%ActOffice%NEQ 0 for/f"tokens=2 delims=="%%G in('"wmic path %spp% where (ApplicationId='%_oApp%' and Description like '%%KMSCLIENT%%') get ID /VALUE"') do (set app=%%G&call :sppchkoff)
if%AUR%EQU 0 (
call:cKMS%_Nul3%
call:cREG%_Nul3%
@ -494,18 +501,18 @@ wmic path %spp% where ID='%app%' get Name > "!_temp!\sppchk.txt"
wmic path %spp% where (PartialProductKey is not NULL) get ID %_Nul2%| findstr /i "%app%"%_Nul1%&&(echo.&call:activate%app%&exit /b)
for/f"tokens=3 delims==, "%%G in('"wmic path %spp% where ID='%app%' get Name /value"')dosetOffVer=%%G
call:offchk%OffVer%
exit /b
:sppchkwin
setoffice=0
if%winbuild%GEQ 14393 if%gvlk%EQU 0 wmic path %spp% where (Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL) get Name %_Nul2%| findstr /i Windows %_Nul1%&&(setgvlk=1)
set_office=0
if%winbuild%GEQ 14393 if%_gvlk%EQU 0 wmic path %spp% where (Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL) get Name %_Nul2%| findstr /i Windows %_Nul1%&&(set_gvlk=1)
wmic path %spp% where ID='%app%' get LicenseStatus %_Nul2%| findstr "1"%_Nul1%&&(echo.&call:activate%app%&exit /b)
wmic path %spp% where (PartialProductKey is not NULL) get ID %_Nul2%| findstr /i "%app%"%_Nul1%&&(echo.&call:activate%app%&exit /b)
wmic path %spp% where (LicenseStatus='1' and Description like '%%KMSCLIENT%%') get Name %_Nul2%| findstr /i "Windows"%_Nul3%&&(exit /b)
echo.
wmic path %spp% where (LicenseStatus='1' and GracePeriodRemaining='0' and PartialProductKey is not NULL) get Name %_Nul2%| findstr /i "Windows"%_Nul3%&&(
setWinPerm=1
)
if%WinPerm%EQU 0 (
wmic path %spp% where "ApplicationID='%wApp%' and LicenseStatus='1'" get Name %_Nul2%| findstr /i "Windows"%_Nul3%&&(
for/f"tokens=%tok% delims=, "%%G in('"wmic path %spp% where (ApplicationID='%wApp%' and LicenseStatus='1') get Description /VALUE"') do set "channel=%%G"
wmic path %spp% where "ApplicationID='%_wApp%' and LicenseStatus='1'" get Name %_Nul2%| findstr /i "Windows"%_Nul3%&&(
for/f"tokens=%tok% delims=, "%%G in('"wmic path %spp% where (ApplicationID='%_wApp%' and LicenseStatus='1') get Description /VALUE"') do set "channel=%%G"
if%OsppHook%EQU 0 (echo.&echo No Installed Office %aword% Product Detected...&exit /b)
wmic path %spp% where (Description like '%%KMSCLIENT%%') get Name /VALUE %_Nul3%||(echo.&echo Detected Office %aword% do not support KMS activation...&echo Retail Products need to be converted to Volume first.&exit /b)