1
+ @ echo off
2
+ set ClearKMSCache = 1
3
+
4
+ set KMS_Emulation = 1
5
+ set KMS_IP = 172.16.0.2
6
+ set KMS_Port = 1688
7
+ set KMS_ActivationInterval = 120
8
+ set KMS_RenewalInterval = 10080
9
+ set KMS_HWID = 0x3A1C049600B60076
10
+ set Windows = Random
11
+ set Office2010 = Random
12
+ set Office2013 = Random
13
+ set Office2016 = Random
14
+ set Office2019 = Random
15
+
16
+ %windir% \system32\reg.exe query " HKU\S-1-5-19" > nul 2 >& 1 || (
17
+ echo ==== ERROR ====
18
+ echo This script require administrator privileges.
19
+ echo To do so, right click on this script and select 'Run as administrator'
20
+ echo .
21
+ echo Press any key to exit...
22
+ pause > nul
23
+ goto :eof
24
+ )
25
+ title SppExtComObjPatcher
26
+ setlocal EnableExtensions EnableDelayedExpansion
27
+ cd /d " %~dp0 "
28
+ IF /I " %PROCESSOR_ARCHITECTURE% " EQU " AMD64" (set xOS=x64) else (set xOS=Win32)
29
+ set " IFEO = HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"
30
+ set " OSPP = HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform"
31
+ set " SPPk = SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
32
+ wmic path SoftwareLicensingProduct where (Description like '%% KMSCLIENT%% ') get Name 2 > nul | findstr /i Windows 1 > nul && (set SppHook=1) || (set SppHook=0)
33
+ wmic path OfficeSoftwareProtectionService get Version > nul 2 >& 1 && (set OsppHook=1) || (set OsppHook=0)
34
+
35
+ for /f " tokens=6 delims=[]. " %%G in ('ver') do set winbuild = %%G
36
+ if %winbuild% GEQ 9200 (
37
+ set OSType = Win8
38
+ set OffVer = 2010
39
+ ) else if %winbuild% GEQ 7600 (
40
+ set OSType = Win7
41
+ set OffVer = 2010/2013/2016/2019
42
+ ) else (
43
+ goto :UnsupportedVersion
44
+ )
45
+
46
+ echo .
47
+ echo Microsoft (R) Windows Software Licensing.
48
+ echo Copyright (C) Microsoft Corporation. All rights reserved.
49
+ echo =========================================================
50
+ echo .
51
+ IF EXIST " %SystemRoot% \system32\SppExtComObj*.dll" goto :uninst
52
+
53
+ :inst
54
+ choice /C YN /N /M " SppExtComObjPatcher will be installed on your computer. Continue? [y/n]: "
55
+ IF ERRORLEVEL 2 exit
56
+ call :StopService sppsvc
57
+ if %OsppHook% NEQ 0 call :StopService osppsvc
58
+ if %winbuild% GEQ 9600 (
59
+ WMIC /NAMESPACE:\\root\Microsoft\Windows\Defender PATH MSFT_MpPreference call Add ExclusionPath=" %SystemRoot% \system32\SppExtComObjHook.dll" > nul 2 >& 1
60
+ )
61
+ echo .
62
+ echo Copying Files...
63
+ copy /y " %xOS% \SppExtComObjHook.dll" " %SystemRoot% \system32" > nul 2 >& 1 && (echo Copied SppExtComObjHook.dll) || (echo SppExtComObjHook.dll Failed& pause& exit)
64
+ echo .
65
+ echo Creating Registry Entries...
66
+ if %OSType% EQU Win8 (
67
+ echo SppExtComObj.exe of Windows 8/8.1/10 - Office 2013/2016/2019
68
+ call :CreateIFEOEntry SppExtComObj.exe
69
+ )
70
+ if %OSType% EQU Win7 if %SppHook% NEQ 0 (
71
+ echo sppsvc.exe of Windows 7
72
+ call :CreateIFEOEntry sppsvc.exe
73
+ )
74
+ echo osppsvc.exe of Office %OffVer%
75
+ call :CreateIFEOEntry osppsvc.exe
76
+ goto :End
77
+
78
+ :uninst
79
+ choice /C YN /N /M " SppExtComObjPatcher will be removed from your computer. Continue? [y/n]: "
80
+ IF ERRORLEVEL 2 exit
81
+ call :StopService sppsvc
82
+ if %OsppHook% NEQ 0 call :StopService osppsvc
83
+ echo .
84
+ echo Removing Installed Files...
85
+ if exist " %SystemRoot% \system32\SppExtComObjHook.dll" (
86
+ echo SppExtComObjHook.dll
87
+ del /f /q " %SystemRoot% \system32\SppExtComObjHook.dll"
88
+ )
89
+ if exist " %SystemRoot% \system32\SppExtComObjPatcher.dll" (
90
+ echo SppExtComObjPatcher.dll
91
+ del /f /q " %SystemRoot% \system32\SppExtComObjPatcher.dll"
92
+ )
93
+ if exist " %SystemRoot% \system32\SppExtComObjPatcher.exe" (
94
+ echo SppExtComObjPatcher.exe
95
+ del /f /q " %SystemRoot% \system32\SppExtComObjPatcher.exe"
96
+ )
97
+ echo .
98
+ echo Removing Registry Entries...
99
+ if %OSType% EQU Win8 (
100
+ echo SppExtComObj.exe of Windows 8/8.1/10 - Office 2013/2016/2019
101
+ call :RemoveIFEOEntry SppExtComObj.exe
102
+ )
103
+ if %OSType% EQU Win7 if %SppHook% NEQ 0 (
104
+ echo sppsvc.exe of Windows 7
105
+ call :RemoveIFEOEntry sppsvc.exe
106
+ )
107
+ echo osppsvc.exe of Office %OffVer%
108
+ call :RemoveIFEOEntry osppsvc.exe
109
+ if %ClearKMSCache% EQU 1 (
110
+ echo .
111
+ echo Clearing KMS Cache...
112
+ call :cKMS SoftwareLicensingProduct SoftwareLicensingService
113
+ if %OsppHook% NEQ 0 call :cKMS OfficeSoftwareProtectionProduct OfficeSoftwareProtectionService
114
+ )
115
+ if %winbuild% GEQ 9600 (
116
+ reg delete " HKLM\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform" /v " NoGenTicket" /f > nul 2 >& 1
117
+ schtasks /delete /f /tn " \Microsoft\Windows\SoftwareProtectionPlatform\SvcTrigger" > nul 2 >& 1
118
+ WMIC /NAMESPACE:\\root\Microsoft\Windows\Defender PATH MSFT_MpPreference call Remove ExclusionPath=" %SystemRoot% \system32\SppExtComObjHook.dll" > nul 2 >& 1
119
+ WMIC /NAMESPACE:\\root\Microsoft\Windows\Defender PATH MSFT_MpPreference call Remove ExclusionPath=" %SystemRoot% \system32\SppExtComObjPatcher.dll" > nul 2 >& 1
120
+ WMIC /NAMESPACE:\\root\Microsoft\Windows\Defender PATH MSFT_MpPreference call Remove ExclusionPath=" %SystemRoot% \system32\SppExtComObjPatcher.exe" > nul 2 >& 1
121
+ )
122
+ goto :End
123
+
124
+ :StopService
125
+ sc query %1 | find /i " STOPPED" > nul || net stop %1 /y > nul 2 >& 1
126
+ sc query %1 | find /i " STOPPED" > nul || sc stop %1 > nul 2 >& 1
127
+ goto :EOF
128
+
129
+ :CreateIFEOEntry
130
+ reg add " %IFEO% \%1 " /f /v Debugger /t REG_SZ /d " rundll32.exe SppExtComObjHook.dll,PatcherMain" > nul 2 >& 1
131
+ reg add " %IFEO% \%1 " /f /v KMS_Emulation /t REG_DWORD /d %KMS_Emulation% > nul 2 >& 1
132
+ reg add " %IFEO% \%1 " /f /v KMS_ActivationInterval /t REG_DWORD /d %KMS_ActivationInterval% > nul 2 >& 1
133
+ reg add " %IFEO% \%1 " /f /v KMS_RenewalInterval /t REG_DWORD /d %KMS_RenewalInterval% > nul 2 >& 1
134
+ if /i %1 NEQ osppsvc.exe (
135
+ reg add " %IFEO% \%1 " /f /v Windows /t REG_SZ /d " %Windows% " > nul 2 >& 1
136
+ if %winbuild% GEQ 9200 for %%A in (2013,2016,2019) do reg add " %IFEO% \%1 " /f /v Office%%A /t REG_SZ /d " !Office%%A ! " > nul 2 >& 1
137
+ )
138
+ if /i %1 EQU osppsvc.exe (
139
+ reg add " %IFEO% \%1 " /f /v Office2010 /t REG_SZ /d " %Office2010% " > nul 2 >& 1
140
+ if %winbuild% LSS 9200 for %%A in (2013,2016,2019) do reg add " %IFEO% \%1 " /f /v Office%%A /t REG_SZ /d " !Office%%A ! " > nul 2 >& 1
141
+ reg add " %OSPP% " /f /v KeyManagementServiceName /t REG_SZ /d %KMS_IP% > nul 2 >& 1
142
+ reg add " %OSPP% " /f /v KeyManagementServicePort /t REG_SZ /d %KMS_Port% > nul 2 >& 1
143
+ )
144
+ if /i %1 EQU SppExtComObj.exe if %winbuild% GEQ 9600 (
145
+ reg add " %IFEO% \%1 " /f /v KMS_HWID /t REG_QWORD /d " %KMS_HWID% " > nul 2 >& 1
146
+ )
147
+ goto :EOF
148
+
149
+ :RemoveIFEOEntry
150
+ if /i %1 NEQ osppsvc.exe (
151
+ reg delete " %IFEO% \%1 " /f > nul 2 >& 1
152
+ goto :EOF
153
+ )
154
+ for %%A in (Debugger,KMS_Emulation,KMS_ActivationInterval,KMS_RenewalInterval,Office2010,Office2013,Office2016,Office2019) do reg delete " %IFEO% \%1 " /f /v %%A > nul 2 >& 1
155
+ if %ClearKMSCache% EQU 1 (
156
+ reg delete " %OSPP% " /f /v KeyManagementServiceName > nul 2 >& 1
157
+ reg delete " %OSPP% " /f /v KeyManagementServicePort > nul 2 >& 1
158
+ )
159
+ goto :EOF
160
+
161
+ :cKMS
162
+ set spp = %1
163
+ set sps = %2
164
+ for /f " tokens=2 delims==" %%G in ('" wmic path %spp% where (Description like '%%K MSCLIENT%% ') get ID /VALUE" 2^ > nul ') do (set app=%%G & call :Clear)
165
+ for /f " tokens=2 delims==" %%A in ('" wmic path %sps% get Version /VALUE" ') do set ver = %%A
166
+ wmic path %sps% where version='%ver% ' call ClearKeyManagementServiceMachine > nul 2 >& 1
167
+ wmic path %sps% where version='%ver% ' call ClearKeyManagementServicePort > nul 2 >& 1
168
+ wmic path %sps% where version='%ver% ' call DisableKeyManagementServiceDnsPublishing 1 > nul 2 >& 1
169
+ wmic path %sps% where version='%ver% ' call DisableKeyManagementServiceHostCaching 1 > nul 2 >& 1
170
+ if /i %1 EQU SoftwareLicensingProduct (
171
+ reg delete " HKLM\%SPPk% \55c92734-d682-4d71-983e-d6ec3f16059f" /f > nul 2 >& 1
172
+ reg delete " HKLM\%SPPk% \0ff1ce15-a989-479d-af46-f275c6370663" /f > nul 2 >& 1
173
+ reg delete " HKEY_USERS\S-1-5-20\%SPPk% \55c92734-d682-4d71-983e-d6ec3f16059f" /f > nul 2 >& 1
174
+ reg delete " HKEY_USERS\S-1-5-20\%SPPk% \0ff1ce15-a989-479d-af46-f275c6370663" /f > nul 2 >& 1
175
+ ) else (
176
+ reg delete " %OSPP% \59a52881-a989-479d-af46-f275c6370663" /f > nul 2 >& 1
177
+ reg delete " %OSPP% \0ff1ce15-a989-479d-af46-f275c6370663" /f > nul 2 >& 1
178
+ )
179
+ goto :EOF
180
+
181
+ :Clear
182
+ wmic path %spp% where ID='%app% ' call ClearKeyManagementServiceMachine > nul 2 >& 1
183
+ wmic path %spp% where ID='%app% ' call ClearKeyManagementServicePort > nul 2 >& 1
184
+ goto :EOF
185
+
186
+ :UnsupportedVersion
187
+ echo ==== ERROR ====
188
+ echo Unsupported OS version Detected.
189
+ echo Project is supported only for Windows 7/8/8.1/10 and their Server equivalent.
190
+ echo .
191
+ echo Press any key to exit...
192
+ pause > nul
193
+ goto :EOF
194
+
195
+ :End
196
+ echo .
197
+ echo Done.
198
+ echo Press any key to exit...
199
+ pause > nul
200
+ goto :EOF
0 commit comments