KMS_VL_ALL - Smart Activation Script

A batch script(s) to automate the activation of supported Windows and Office products using local KMS server emulator or an external server.
Designed to be unattended and smart enough not to override the permanent activation of products (Windows or Office),
only non-activated products will be KMS-activated (if supported).
The ultimate feature of this solution when installed, will provide 24/7 activation, whenever the system itself requests it (renewal, reactivation, hardware change, Edition upgrade, new Office...), without needing interaction from the user.
Some security programs will report infected files due to KMS emulating (see source code near the end),
this is false-positive, as long as you download the file from the trusted Home Page.
wmic.exe tool is removed from Windows 11 build 22483 and later.
In order to overcome this, KMS_VL_ALL v45 and later incorporate simple VBScripts to query and execute WMI functions.
This require Windows Script Host to be working and not disabled.
Furthermore, be advised, this may increase the ratio for marking the script(s) as a security threat.



How does it work?
Key Management Service (KMS) is a genuine activation method provided by Microsoft for volume licensing customers (organizations, schools or governments).
The machines in those environments (called KMS clients) activate via the environment KMS host server (authorized Microsoft's licensing key), not via Microsoft activation servers.
By design, the KMS activation period lasts up to 180 Days (6 Months) at max, with the ability to renew and reinstate the period at any time.
With the proper auto renewal configuration, it will be a continuous activation (essentially permanent).
KMS Emulators (server and client) are sophisticated tools based on the reversed engineered KMS protocol.
It mimics the KMS server/client communications, and provide a clean activation for the supported KMS clients, without altering or hacking any system files integrity.
Updates for Windows or Office do not affect or block KMS activation, only a new KMS protocol will not work with the local emulator.
The mechanism of SppExtComObjPatcher makes it act as a ready-on-request KMS server, providing instant activation without external schedule tasks or manual intervention.
Including auto renewal, auto activation of volume Office afterward, reactivation because of hardware change, date change, windows or office edition change... etc.
On Windows 7, later installed Office may require initiating the first activation vis OSPP.vbs or the script, or opening Office program.
That feature makes use of the "Image File Execution Options" technique to work, programmed as an Application Verifier custom provider for the system file responsible for the KMS process.
Hence, OS itself handle the DLL injection, allowing the hook to intercept the KMS activation request and write the response on the fly.
On Windows 8.1/10, it also handles the localhost restriction for KMS activation and redirects any local/private IP address as it were external (different stack).
KMS_VL_ALL scripts make use of Windows Management Instrumentation WMI utilities, which query the properties and executes the methods of Windows and Office licensing classes,
providing a native activation processing, which is almost identical to the official VBScript tools slmgr.vbs and ospp.vbs, but in an automated way.
The script(s) make these changes to the system (if the emulator is used):
copy or link the file "C:\Windows\System32\SppExtComObjHook.dll"
add the hook registry keys to "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"
add osppsvc.exe keys to "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform"
create schedule task "\Microsoft\Windows\SoftwareProtectionPlatform\SvcTrigger" (on Windows 8 and later)



Supported Products
Volume-capable:

Windows 10/11:
Enterprise, Enterprise LTSC/LTSB, Enterprise G, Enterprise multi-session, Enterprise, Education, Pro, Pro Workstation, Pro Education, Home, Home Single Language, Home China

Windows 8.1:
Enterprise, Pro, Pro with Media Center, Core, Core Single Language, Core China, Pro for Students, Bing, Bing Single Language, Bing China, Embedded Industry Enterprise/Pro/Automotive

Windows 8:
Enterprise, Pro, Pro with Media Center, Core, Core Single Language, Core China, Embedded Industry Enterprise/Pro

Windows 10/11 on ARM64 is supported. Windows 8/8.1/10/11 N editions variants are also supported (e.g. Pro N)

Windows 7:
Enterprise /N/E, Professional /N/E, Embedded POSReady/ThinPC

Windows Server 2022/2019/2016:
LTSC editions (Standard, Datacenter, Essentials, Cloud Storage, Azure Core, Server ARM64), SAC editions (Standard ACor, Datacenter ACor, Azure Datacenter)

Windows Server 2012 R2:
Standard, Datacenter, Essentials, Cloud Storage

Windows Server 2012:
Standard, Datacenter, MultiPoint Standard, MultiPoint Premium

Windows Server 2008 R2:
Standard, Datacenter, Enterprise, MultiPoint, Web, HPC Cluster

Office Volume 2010 / 2013 / 2016 / 2019 / 2021





How To Use



Remove any other KMS solutions.
Temporary suspend Antivirus realtime protection, or exclude the downloaded file and the extracted folder from scanning to avoid quarantine.
If you are using Windows Defender on Windows 11, 10 or 8.1, the script automatically adds an exclusion for C:\Windows\System32\SppExtComObjHook.dll
therefore, it's best not to disable Windows Defender, and instead exclude the downloaded file and the extracted folder before running the script(s).
Extract the downloaded file contents to a simple path without special characters or long spaces.
Administrator rights are required to run the activation script(s).
KMS_VL_ALL offer 3 flavors of activation modes.

Activation Modes

Auto Renewal
Recommended mode, where you only need to install the activation emulator once. Afterward, the system itself handle and renew activation per schedule.

To run this mode:

run AutoRenewal-Setup.cmd, press Y to approve the installation
it will automatically execute Activate.cmd
If you use Antivirus software, make sure to exclude this file from real-time protection:
C:\Windows\System32\SppExtComObjHook.dll

If you later installed Volume Office product(s), it will be auto activated in this mode.

Additionally, If you want to convert and activate Office C2R, renew the activation, or activate new products:

just run Activate.cmd
On Windows 8 and later, the script duplicate inbox system schedule task SvcRestartTaskLogon to SvcTrigger
this is just a precaution step to insure that the auto renewal period is evaluated and respected, it's not directly related to activation itself, and you can manually remove it.

To remove this mode:

run AutoRenewal-Setup.cmd, press Y to approve the removal
____________________________________________________________


Manual
No remnants mode, where you only need to run Activate.cmd, and then any KMS emulator traces will be cleared from the system.

To run this mode:

make sure that auto renewal solution is not installed, or remove it
then, just run Activate.cmd
You will have to run Activate.cmd again to activate newly installed products (e.g. Office) or if Windows edition is switched.

You will have to run Activate.cmd again to activate before the KMS activation period expires.

You can run and activate anytime during that period to renew the period to the max interval.

If Activate.cmd is accidentally terminated before it completes the process, run the script again to clean any leftovers.

____________________________________________________________


External
Standalone mode, where you only need the file Activate.cmd alone, previously refered to as "Online KMS".

You can use Activate.cmd to activate against trusted external KMS server, without needing other files or using local KMS emulator functions.

The external server can be a web address, or a network IP address (local LAN or VM).

To run this mode:

edit Activate.cmd with Notepad (or text editor)
change External=0 to 1
change KMS_IP=172.16.0.2 to the IP/address of the server
save the script, and then run
If you later installed Volume Office product(s), it will be auto activated if the external server is still connected.

The used server address will be left registered in the system to allow activated products to auto renew against it,
if the server is no longer available, you will need to run the mode again with a new available server.




Additional Options

Activation Choice
Activate.cmd is set by default to process and try to activate both Windows and Office.

However, if you want to turn OFF processing Windows or Office, for whatever reason:

you afraid it may override permanent activation
you want to speed up the operation (you have Windows or Office already permanently activated)
you want to activate Windows or Office later on your terms
To do that:

edit Activate.cmd with Notepad (or text editor)
change ActWindows=1 to zero 0 if tou want to skip Windows
change ActOffice=1 to zero 0 if you want to skip Office
save the script, and then run
Notice:
this turn OFF is not very effective if Windows or Office installation is already Volume (GVLK installed),
because the system itself may try to reach and KMS activate the products, especially on Windows 8 and later.

______________________________

Convert Office C2R-R2V
Activate.cmd is set by default to auto convert detected Office C2R Retail to Volume (except activated Retail products).

However, if you prefer to turn OFF this function:

edit Activate.cmd with Notepad (or text editor)
change AutoR2V=1 to zero 0
save the script, and then run
______________________________

Skip Windows 10/11 KMS 2038
Activate.cmd is set by default to check and skip Windows activation if KMS 2038 is detected.

However, if you want to revert to normal KMS activation:

edit Activate.cmd with Notepad (or text editor)
change SkipKMS38=1 to zero 0
save the script, and then run
Notice:
On Windows 10/11, if SkipKMS38 is ON (default), Windows will always get checked and processed, even if Process Windows is No

______________________________

Advanced KMS Options
You can manually modify these KMS-related options by editing Activate.cmd with Notepad before running.

KMS_RenewalInterval
Set the interval for KMS auto renewal schedule (default is 10080 = weekly)
this only have much effect on Auto Renewal or External modes
allowed values in minutes: from 15 to 43200
KMS_ActivationInterval
Set the interval for KMS reattempt schedule for failed activation renewal, or unactivated products to attemp activation
this does not affect the overall KMS period (180 Days), or the renewal schedule
allowed values in minutes: from 15 to 43200
KMS_HWID
Set the Hardware Hash for local KMS emulator server (only affect Windows 8.1/10)
0x prefix is mandatory
KMS_Port
Set TCP port for KMS communications
______________________________

Command line Switches
Activate.cmd switches

Unattended (auto exit):
/u
Silent run (implies Unattended):
/s
Silent and create simple log:
/s /L
Debug mode (implies Unattended):
/d
Silent Debug mode:
/s /d
External activation mode:
/e pseudo.kms.server
Process Windows only:
/w
Process Office only:
/o
Turn OFF Office C2R-R2V conversion:
/c
Do not skip Windows 10/11 KMS38:
/x
AutoRenewal-Setup.cmd switches

Unattended (auto install or remove and exit):
/u
Silent run (implies Unattended):
/s
Silent and create simple log:
/s /L
Debug mode (implies Unattended):
/d
Silent Debug mode:
/s /d
Force installation regardless detection (implies Unattended):
/i
Force removal regardless detection (implies Unattended):
/r
Do not clear KMS cache:
/k
Rules:

All switches are case-insensitive, works in any order, but must be separated with spaces.
You can specify multiple switches together.
If Activate.cmd switch /e is specified without server address, it will be changed to Manual or Auto (depending on SppExtComObjHook.dll presence).
If Activate.cmd switches /o /w are specified together, the last one takes precedence.
If AutoRenewal-Setup.cmd switches /i /r are specified together, the last one takes precedence.
Log switch /L only works with Silent switch /s
Examples:


Activate.cmd /s /e pseudo.kms.server
Activate.cmd /d /w /o
Activate.cmd /u /x /e pseudo.kms.server
AutoRenewal-Setup.cmd /s /r /k
AutoRenewal-Setup.cmd /i /u 
AutoRenewal-Setup.cmd /s /l

    
Remarks:

In general, Windows batch scripts do not work well with unusual folder paths and files name, which contain non-ascii and unicode characters, long paths and spaces, or some of these special characters ` ~ ; ' , ! @ % ^ & ( ) [ ] { } + =
KMS_VL_ALL scripts are coded to correctly handle those limitations, as much as possible.
By default, even explorer context menu option "Run as administrator" will fail to execute on some of those paths.
In order to fix that, open command prompt as administrator, then copy/paste and execute these commands:

set _r=^%SystemRoot^%
reg add HKLM\SOFTWARE\Classes\batfile\shell\runas\command /f /v "" /t REG_EXPAND_SZ /d "%_r%\System32\cmd.exe /C \"\"%1\" %*\""
reg add HKLM\SOFTWARE\Classes\cmdfile\shell\runas\command /f /v "" /t REG_EXPAND_SZ /d "%_r%\System32\cmd.exe /C \"\"%1\" %*\""

    

Check Activation Status
You can use those scripts to check the status of Windows and Office products.

Both scripts do not require running as administrator, a double-click to run is enough.

Check-Activation-Status-vbs:

query and execute official licensing VBScripts: slmgr.vbs for Windows, ospp.vbs for Office
shows the activation expiration date for Windows
Office 2010 ospp.vbs shows a very little info
Check-Activation-Status-wmi:

query and execute WMI functions using wmic.exe or VBScripts
shows extra more info (SKU ID, key channel)
shows the activation expiration date for all products
shows more detailed info for Office 2010
can show the status of Office UWP apps
implement vNextDiag.ps1 functions to detect new Office 365 vNext licenses and subscriptions

Setup Preactivate
To preactivate the system during Windows installation, copy $oem$ folder to sources folder in the installation installation media (ISO/USB).

If you already use another setupcomplete.cmd, rename this one to KMS_VL_ALL.cmd or similar name
then add a command to run it in your setupcomplete.cmd, example:
call KMS_VL_ALL.cmd

Notes:

The included setupcomplete.cmd is set by default to Auto Renewal mode. You can also change it to External mode
The included setupcomplete.cmd support the Additional Options described previously, except Command line Switches.
Later, if you want to uninstall the project, use AutoRenewal-Setup.cmd
On Windows 8 and later, running setupcomplete.cmd is disabled if the default installed key for the edition is OEM Channel.





Troubleshooting



If the activation failed at first attempt:

Run Activate.cmd one more time.
Reboot the system and try again.
Verify that Antivirus software is not blocking C:\Windows\SppExtComObjHook.dll
Check System integrity, open command prompt as administrator, and execute these command respectively:
for Windows 11, 10, or 8.1 only: Dism /online /Cleanup-Image /RestoreHealth
then, for any OS: sfc /scannow
if Auto-Renewal is installed already, but the activation started to fail, run AutoRenewal-Setup.cmd to Uninstall Completely then run it again for installation.

For Windows 7, if you have the errors described in KB4487266, execute the suggested fix.

If you got Error 0xC004F035 on Windows 7, it means your Machine is not qualified for KMS activation. For more info, see here and here.

If you got Error 0x80040154, it is mostly related to misconfigured Windows 10/11 KMS38 activation, rearm the system and start over, or revert to Normal KMS.

If you got Error 0xC004E015, it is mostly related to misconfigured Office retail to volume conversion, try to reinstall system licenses:
cscript //Nologo %SystemRoot%\System32\slmgr.vbs /rilc

If you got one of these Errors on Windows Server, verify that the system is properly converted from Evaluation to Retail/Volume:
0xC004E016 - 0xC004F014 - 0xC004F034

If the activation still failed after the above tips, you may enable the debug mode to help determine the reason:

run Activate.cmd with command line switch: Activate.cmd /d
OR
edit Activate.cmd with Notepad (or text editor)
change _Debug=0 to 1
save the script, and then run
wait until the operation is finished and Debug.log is created
upload or post the log file on the home page (MDL forums) for inspection



