65 Commits

Author SHA1 Message Date
WindowsAddict
deb74ab9b8 Optimize DISM restore and SFC scan log creation 2024-08-17 02:28:32 +05:30
WindowsAddict
d08ed1bd38 Update Troubleshoot script with 2.7 structure 2024-08-17 01:41:42 +05:30
WindowsAddict
5f5a51322d Realign lines related to dashboard app info 2024-08-16 05:14:16 +05:30
WindowsAddict
fd0e25f477 Detect Ohook install in KMS script 2024-08-16 04:34:19 +05:30
WindowsAddict
b33dcb2f72 Update OEM folder script 2024-08-16 04:12:38 +05:30
WindowsAddict
117ba004f0 better check for malware if sppsvc.exe is not found 2024-08-16 03:03:12 +05:30
WindowsAddict
b0d898973f Change wording 2024-08-16 03:00:58 +05:30
WindowsAddict
63b3c5097b Show info regarding Office dashboard app in KMS script 2024-08-14 09:20:42 +05:30
WindowsAddict
69430c6458 Don't create renewal task if VL IDs not found or OEMBIOS error is present and Office VL IDs not found 2024-08-14 08:46:43 +05:30
WindowsAddict
9f57f585d5 Don't show fix licensing solution in some more cases 2024-08-14 06:44:43 +05:30
WindowsAddict
52decdde18 Replace hyphen from evaluation-editions URL 2024-08-13 05:36:51 +05:30
WindowsAddict
601bd0e420 Add old preview edition keys in KMS38 2024-08-05 06:42:49 +05:30
WindowsAddict
5e4988a634 Add more KMS keys for old preview editions 2024-08-05 06:15:01 +05:30
WindowsAddict
3a050f2da7 Fix eval edition change and show .net 3.5 status 2024-08-04 14:06:08 +05:30
WindowsAddict
31b55fd0e3 Add two more preview editions and sort all of them
EmbeddedIndustryE_TAP-CTP
EmbeddedIndustryE_Beta
2024-07-31 21:38:39 +05:30
WindowsAddict
62d5d5442e Add old preview editions in KMS script 2024-07-31 15:52:49 +05:30
WindowsAddict
f2e6e6e389 Fix SID code in KMS script 2024-07-31 15:19:32 +05:30
WindowsAddict
b5a305a14e Highlight options if unsupported product is detected 2024-07-31 06:35:36 +05:30
WindowsAddict
6c71e82ef3 Fig a bug in server section 2024-07-30 08:56:25 +05:30
WindowsAddict
66e8cda508 Add timeout 2024-07-30 08:43:48 +05:30
WindowsAddict
98027af16d Compress generated logs 2024-07-30 08:41:48 +05:30
WindowsAddict
be45752a21 Add info about edition ID difference 2024-07-30 06:21:01 +05:30
WindowsAddict
a421b12ae4 Add info about how to use a different sppc.dll file 2024-07-29 20:43:55 +05:30
WindowsAddict
d06185d7f7 Highlight skipping of Office activation 2024-07-29 20:31:28 +05:30
WindowsAddict
a46bb78e5e Show info about buy button in Office dashboard app for Zoomers 2024-07-29 01:48:14 +05:30
WindowsAddict
2470963537 Inform to check antivirus block if dll extraction fails 2024-07-28 22:36:55 +05:30
WindowsAddict
89bff68b28 Fix pkeyconfig path 2024-07-28 22:33:18 +05:30
WindowsAddict
191121c3d4 Add more checks in checking user profile SID's 2024-07-28 22:25:36 +05:30
WindowsAddict
7bf55fc6ee Fix bug where 'NETWORK SERVICE' translation is needed 2024-07-28 19:22:13 +05:30
WindowsAddict
816925bfef Ignore log deletion error 2024-07-28 08:03:09 +05:30
WindowsAddict
ad45cf0926 Add red color 2024-07-28 06:56:54 +05:30
WindowsAddict
29eb5bd60d Generate clean logs on desktop on edition change failure and other fixes 2024-07-28 06:54:15 +05:30
WindowsAddict
70b754657f Use random GUID instead of %random% 2024-07-23 07:14:24 +05:30
WindowsAddict
8b58696455 Add a check for old renewal task detection 2024-07-23 06:54:47 +05:30
WindowsAddict
5d47723d07 Show fix_powershell link 2024-07-23 05:12:02 +05:30
WindowsAddict
2b786e3037 Correct a info line in KMS script 2024-07-23 03:17:56 +05:30
WindowsAddict
4451a25e7f Differentiate between new and old outlook detection 2024-07-21 05:02:51 +05:30
WindowsAddict
886745f103 Detect sandboxing 2024-07-21 04:31:33 +05:30
WindowsAddict
5728ba2686 Add check for NT SERVICE\sppsvc 2024-07-20 03:13:45 +05:30
WindowsAddict
ddccc4025f Optimize the code
Thanks to abbodi1406
2024-07-19 21:32:28 +05:30
WindowsAddict
1567903b09 Improve device-based-licensing cleaning 2024-07-19 20:21:27 +05:30
WindowsAddict
f6125eaa5b Add comment about S-1-5-20 SPP registry issue 2024-07-19 20:06:52 +05:30
WindowsAddict
07c4fcdc74 Improve error check of SPP in HKU\S-1-5-20 2024-07-18 04:36:50 +05:30
WindowsAddict
962f7e326a Remove duplicacy of file infector checks 2024-07-17 03:54:38 +05:30
WindowsAddict
6f88a4bf90 More accurate check for Office Products in NoEditionChange mode 2024-07-17 01:19:06 +05:30
WindowsAddict
dd3d788bfa Fix these bugs in checking activated products
Issue when similar names products are installed, like O365ProPlusRetail and ProPlusRetail
Issue in detecting SPDRetail 2013 because of different name in LicenseFamily
2024-07-16 20:03:19 +05:30
WindowsAddict
3d16fc6a07 Improve/Fix error messages when key is not found 2024-07-16 17:01:13 +05:30
WindowsAddict
e1b9942223 Remove unsupported EnterpriseSN keys 2024-07-15 17:21:40 +05:30
WindowsAddict
53cda879c1 Add VL IDs in ProductReleaseIds in old Office builds 2024-07-14 03:42:48 +05:30
WindowsAddict
211835666b Separate label for malware check
To also call it at the start
2024-07-14 02:29:11 +05:30
WindowsAddict
bdb9875a6b Remove check activation status scripts and replace them with @abbodi1406's CAS
https://gravesoft.dev/cas
2024-07-13 04:46:38 +05:30
WindowsAddict
5b694779be Remove notx86 check in KMS script and run /reg:32 regardless 2024-07-13 04:37:16 +05:30
WindowsAddict
b7c3f9a98a Shorten the Windows Subscription check code 2024-07-13 04:18:44 +05:30
WindowsAddict
48fb5fc5fe 2.7 Preview 2024-07-13 03:56:18 +05:30
WindowsAddict
d3f2cd8806 Evade AV's detection - 6 2024-07-05 15:42:00 +05:30
WindowsAddict
8cdde879b2 Fix the broken Discord banner 2024-06-09 06:24:56 +05:30
WindowsAddict
0884271c4f Evade AV's detection - 5 2024-05-31 02:33:47 +05:30
WindowsAddict
e752461568 Evade AV's detection - 4 2024-05-27 07:54:12 +05:30
WindowsAddict
d14b3b46a0 Update readme 2024-05-27 07:44:10 +05:30
WindowsAddict
819140de46 Update the command with the new domain
More info: https://massgrave.dev/news
2024-05-21 00:28:31 +05:30
WindowsAddict
fc7e9f019d Add Tls12 info 2024-05-17 14:55:26 +05:30
WindowsAddict
36f7291963 Evade AV's detection - 3 2024-05-12 17:52:22 +05:30
WindowsAddict
9556ad2cbe Evade AV's detection - 2 2024-05-09 12:38:23 +05:30
WindowsAddict
71e575e7b6 Evade AV's detection - 1 2024-04-30 18:03:32 +05:30
WindowsAddict
355ccb7f29 Revert export-ignore 2024-04-20 18:10:49 +05:30
13 changed files with 7708 additions and 6525 deletions

6
.gitattributes vendored
View File

@@ -1,3 +1,3 @@
MAS export-ignore # MAS export-ignore
LICENSE export-ignore # LICENSE export-ignore
README.md export-ignore # README.md export-ignore

View File

@@ -4,15 +4,13 @@
:: For command line switches, check mass grave[.]dev/command_line_switches.html :: For command line switches, check mass grave [.] dev/command_line_switches.html
:: If you want to better understand script, read from MAS separate files version. :: If you want to better understand script, read from MAS separate files version.
::============================================================================ ::============================================================================
:: ::
:: This script is a part of 'Microsoft-Activation-Scripts' (MAS) project. :: Homepage: mass grave [.] dev
::
:: Homepage: mass grave[.]dev
:: Email: windowsaddict@protonmail.com :: Email: windowsaddict@protonmail.com
:: ::
::============================================================================ ::============================================================================
@@ -263,7 +261,7 @@ setlocal EnableDelayedExpansion
cls cls
color 07 color 07
title Microsoft_Activation_Scripts %masver% title Microsoft %blank%Activation %blank%Scripts %masver%
mode 76, 30 mode 76, 30
echo: echo:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,259 +0,0 @@
@setlocal DisableDelayedExpansion
@echo off
@cls
:: Check-Activation-Status
:: Written by @abbodi1406
:: forums.mydigitallife.net/posts/838808
set _args=
set _args=%*
for %%A in (%_args%) do (
if /i "%%A"=="-wow" set _rel1=1
if /i "%%A"=="-arm" set _rel2=1
)
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
)
color 07
title Check Activation Status [vbs]
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%"
)
:: Check LF line ending
pushd "%~dp0"
>nul findstr /v "$" "%~nx0" && (
echo:
echo Error: Script either has LF line ending issue or an empty line at the end of the script is missing.
echo:
ping 127.0.0.1 -n 6 >nul
popd
exit /b
)
popd
set ohook=
for %%# in (15 16) do (
for %%A in ("%ProgramFiles%" "%ProgramW6432%" "%ProgramFiles(x86)%") do (
if exist "%%~A\Microsoft Office\Office%%#\sppc*dll" set ohook=1
)
)
for %%# in (System SystemX86) do (
for %%G in ("Office 15" "Office") do (
for %%A in ("%ProgramFiles%" "%ProgramW6432%" "%ProgramFiles(x86)%") do (
if exist "%%~A\Microsoft %%~G\root\vfs\%%#\sppc*dll" set ohook=1
)
)
)
set "_bit=64"
set "_wow=1"
if /i "%PROCESSOR_ARCHITECTURE%"=="x86" if "%PROCESSOR_ARCHITEW6432%"=="" set "_wow=0"&set "_bit=32"
set "_utemp=%TEMP%"
set "line2=************************************************************"
set "line3=____________________________________________________________"
set _sO16vbs=0
set _sO15vbs=0
if exist "%ProgramFiles%\Microsoft Office\Office15\ospp.vbs" (
set _sO15vbs=1
) else if exist "%ProgramW6432%\Microsoft Office\Office15\ospp.vbs" (
set _sO15vbs=1
) else if exist "%ProgramFiles(x86)%\Microsoft Office\Office15\ospp.vbs" (
set _sO15vbs=1
)
setlocal EnableDelayedExpansion
echo %line2%
echo *** Windows Status ***
echo %line2%
pushd "!_utemp!"
copy /y %SystemRoot%\System32\slmgr.vbs . >nul 2>&1
net start sppsvc /y >nul 2>&1
cscript //nologo slmgr.vbs /dli || (echo Error executing slmgr.vbs&del /f /q slmgr.vbs&popd&goto :casVend)
cscript //nologo slmgr.vbs /xpr
del /f /q slmgr.vbs >nul 2>&1
popd
echo %line3%
if defined ohook (
echo.
echo.
echo %line2%
echo *** Office Ohook Activation Status ***
echo %line2%
echo.
powershell "write-host -back 'Black' -fore 'Yellow' 'Ohook for permanent Office activation is installed.'; write-host -back 'Black' -fore 'Yellow' 'You can ignore below Office activation status.'"
echo.
)
:casVo16
set office=
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\16.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b")
if exist "!office!\ospp.vbs" (
set _sO16vbs=1
echo.
echo %line2%
if %_sO15vbs% EQU 0 (
echo *** Office 2016 %_bit%-bit Status ***
) else (
echo *** Office 2013/2016 Status ***
)
echo %line2%
cscript //nologo "!office!\ospp.vbs" /dstatus
)
if %_wow%==0 goto :casVo13
set office=
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\16.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b")
if exist "!office!\ospp.vbs" (
set _sO16vbs=1
echo.
echo %line2%
if %_sO15vbs% EQU 0 (
echo *** Office 2016 32-bit Status ***
) else (
echo *** Office 2013/2016 Status ***
)
echo %line2%
cscript //nologo "!office!\ospp.vbs" /dstatus
)
:casVo13
if %_sO16vbs% EQU 1 goto :casVo10
set office=
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b")
if exist "!office!\ospp.vbs" (
echo.
echo %line2%
echo *** Office 2013 %_bit%-bit Status ***
echo %line2%
cscript //nologo "!office!\ospp.vbs" /dstatus
)
if %_wow%==0 goto :casVo10
set office=
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b")
if exist "!office!\ospp.vbs" (
echo.
echo %line2%
echo *** Office 2013 32-bit Status ***
echo %line2%
cscript //nologo "!office!\ospp.vbs" /dstatus
)
:casVo10
set office=
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b")
if exist "!office!\ospp.vbs" (
echo.
echo %line2%
echo *** Office 2010 %_bit%-bit Status ***
echo %line2%
cscript //nologo "!office!\ospp.vbs" /dstatus
)
if %_wow%==0 goto :casVc16
set office=
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b")
if exist "!office!\ospp.vbs" (
echo.
echo %line2%
echo *** Office 2010 32-bit Status ***
echo %line2%
cscript //nologo "!office!\ospp.vbs" /dstatus
)
:casVc16
reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath >nul 2>&1 || (
reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun /v InstallPath >nul 2>&1 || goto :casVc13
)
set office=
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath" 2^>nul') do (set "office=%%b\Office16")
if exist "!office!\ospp.vbs" (
set _sO16vbs=1
echo.
echo %line2%
if %_sO15vbs% EQU 0 (
echo *** Office 2016-2021 C2R Status ***
) else (
echo *** Office 2013-2021 Status ***
)
echo %line2%
cscript //nologo "!office!\ospp.vbs" /dstatus
)
if %_wow%==0 goto :casVc13
set office=
for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun /v InstallPath" 2^>nul') do (set "office=%%b\Office16")
if exist "!office!\ospp.vbs" (
set _sO16vbs=1
echo.
echo %line2%
if %_sO15vbs% EQU 0 (
echo *** Office 2016-2021 C2R Status ***
) else (
echo *** Office 2013-2021 Status ***
)
echo %line2%
cscript //nologo "!office!\ospp.vbs" /dstatus
)
:casVc13
if %_sO16vbs% EQU 1 goto :casVc10
reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun /v InstallPath >nul 2>&1 || (
reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun /v InstallPath >nul 2>&1 || goto :casVc10
)
set office=
if exist "%ProgramFiles%\Microsoft Office\Office15\ospp.vbs" (
set "office=%ProgramFiles%\Microsoft Office\Office15"
) else if exist "%ProgramW6432%\Microsoft Office\Office15\ospp.vbs" (
set "office=%ProgramW6432%\Microsoft Office\Office15"
) else if exist "%ProgramFiles(x86)%\Microsoft Office\Office15\ospp.vbs" (
set "office=%ProgramFiles(x86)%\Microsoft Office\Office15"
)
if exist "!office!\ospp.vbs" (
echo.
echo %line2%
echo *** Office 2013 C2R Status ***
echo %line2%
cscript //nologo "!office!\ospp.vbs" /dstatus
)
:casVc10
if %_wow%==0 reg query HKLM\SOFTWARE\Microsoft\Office\14.0\CVH /f Click2run /k >nul 2>&1 || goto :casVend
if %_wow%==1 reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\CVH /f Click2run /k >nul 2>&1 || goto :casVend
set office=
if exist "%ProgramFiles%\Microsoft Office\Office14\ospp.vbs" (
set "office=%ProgramFiles%\Microsoft Office\Office14"
) else if exist "%ProgramW6432%\Microsoft Office\Office14\ospp.vbs" (
set "office=%ProgramW6432%\Microsoft Office\Office14"
) else if exist "%ProgramFiles(x86)%\Microsoft Office\Office14\ospp.vbs" (
set "office=%ProgramFiles(x86)%\Microsoft Office\Office14"
)
if exist "!office!\ospp.vbs" (
echo.
echo %line2%
echo *** Office 2010 C2R Status ***
echo %line2%
cscript //nologo "!office!\ospp.vbs" /dstatus
)
:casVend
echo.
echo Press any key to exit.
pause >nul
exit /b
:: Leave empty line below

View File

@@ -1,564 +0,0 @@
@setlocal DisableDelayedExpansion
@echo off
:: Check-Activation-Status
:: Written by @abbodi1406
:: forums.mydigitallife.net/posts/838808
set WMI_VBS=0
@cls
set _args=
set _args=%*
for %%A in (%_args%) do (
if /i "%%A"=="-wow" set _rel1=1
if /i "%%A"=="-arm" set _rel2=1
)
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
)
color 07
title Check Activation Status [wmi]
set wspp=SoftwareLicensingProduct
set wsps=SoftwareLicensingService
set ospp=OfficeSoftwareProtectionProduct
set osps=OfficeSoftwareProtectionService
set winApp=55c92734-d682-4d71-983e-d6ec3f16059f
set o14App=59a52881-a989-479d-af46-f275c6370663
set o15App=0ff1ce15-a989-479d-af46-f275c6370663
for %%# in (spp_get,ospp_get,cW1nd0ws,sppw,c0ff1ce15,sppo,osppsvc,ospp14,ospp15) do set "%%#="
for /f "tokens=6 delims=[]. " %%# in ('ver') do set winbuild=%%#
set "spp_get=Description, DiscoveredKeyManagementServiceMachineName, DiscoveredKeyManagementServiceMachinePort, EvaluationEndDate, GracePeriodRemaining, ID, KeyManagementServiceMachine, KeyManagementServicePort, KeyManagementServiceProductKeyID, LicenseStatus, LicenseStatusReason, Name, PartialProductKey, ProductKeyID, VLActivationInterval, VLRenewalInterval"
set "ospp_get=%spp_get%"
if %winbuild% GEQ 9200 set "spp_get=%spp_get%, KeyManagementServiceLookupDomain, VLActivationTypeEnabled"
if %winbuild% GEQ 9600 set "spp_get=%spp_get%, DiscoveredKeyManagementServiceMachineIpAddress, ProductKeyChannel"
set "_work=%~dp0"
set "_batf=%~f0"
set "_batp=%_batf:'=''%"
set "_Local=%LocalAppData%"
set _Identity=0
setlocal EnableDelayedExpansion
dir /b /s /a:-d "!_Local!\Microsoft\Office\Licenses\*1*" 1>nul 2>nul && set _Identity=1
dir /b /s /a:-d "!ProgramData!\Microsoft\Office\Licenses\*1*" 1>nul 2>nul && set _Identity=1
pushd "!_work!"
setlocal DisableDelayedExpansion
if %winbuild% LSS 9200 if not exist "%SystemRoot%\servicing\Packages\Microsoft-Windows-PowerShell-WTR-Package~*.mum" set _Identity=0
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%"
)
:: Check LF line ending
pushd "%~dp0"
>nul findstr /v "$" "%~nx0" && (
echo:
echo Error: Script either has LF line ending issue or an empty line at the end of the script is missing.
echo:
ping 127.0.0.1 -n 6 >nul
popd
exit /b
)
popd
set ohook=
for %%# in (15 16) do (
for %%A in ("%ProgramFiles%" "%ProgramW6432%" "%ProgramFiles(x86)%") do (
if exist "%%~A\Microsoft Office\Office%%#\sppc*dll" set ohook=1
)
)
for %%# in (System SystemX86) do (
for %%G in ("Office 15" "Office") do (
for %%A in ("%ProgramFiles%" "%ProgramW6432%" "%ProgramFiles(x86)%") do (
if exist "%%~A\Microsoft %%~G\root\vfs\%%#\sppc*dll" set ohook=1
)
)
)
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
)
if %_cwmi% EQU 0 (
echo:
echo Error: WMI is not responding in the system.
echo:
echo In MAS, Goto Troubleshoot and run Fix WMI option.
echo:
echo Press any key to exit...
pause >nul
exit /b
)
set "line2=************************************************************"
set "line3=____________________________________________________________"
set "_psc=powershell"
set _prsh=1
for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" set _prsh=0
set "_csg=cscript.exe //NoLogo //Job:WmiMulti "%~nx0?.wsf""
set "_csq=cscript.exe //NoLogo //Job:WmiQuery "%~nx0?.wsf""
set "_csx=cscript.exe //NoLogo //Job:XPDT "%~nx0?.wsf""
if %_cwmi% EQU 0 set WMI_VBS=1
if %WMI_VBS% EQU 0 (
set "_zz1=wmic path"
set "_zz2=where"
set "_zz3=get"
set "_zz4=/value"
set "_zz5=("
set "_zz6=)"
set "_zz7="wmic path"
set "_zz8=/value""
) else (
set "_zz1=%_csq%"
set "_zz2="
set "_zz3="
set "_zz4="
set "_zz5=""
set "_zz6=""
set "_zz7=%_csq%"
set "_zz8="
)
set _WSH=0
set OsppHook=1
sc query osppsvc >nul 2>&1
if %errorlevel% EQU 1060 set OsppHook=0
net start sppsvc /y >nul 2>&1
call :casWpkey %wspp% %winApp% cW1nd0ws sppw
if %winbuild% GEQ 9200 call :casWpkey %wspp% %o15App% c0ff1ce15 sppo
if %OsppHook% NEQ 0 (
net start osppsvc /y >nul 2>&1
call :casWpkey %ospp% %o14App% osppsvc ospp14
if %winbuild% LSS 9200 call :casWpkey %ospp% %o15App% osppsvc ospp15
)
echo %line2%
echo *** Windows Status ***
echo %line2%
if not defined cW1nd0ws (
echo.
echo Error: product key not found.
goto :casWcon
)
set winID=1
set "_qr=%_zz7% %wspp% %_zz2% %_zz5%ApplicationID='%winApp%' and PartialProductKey is not null%_zz6% %_zz3% ID %_zz8%"
for /f "tokens=2 delims==" %%# in ('%_qr%') do (
set "chkID=%%#"
call :casWdet "%wspp%" "%wsps%" "%spp_get%"
call :casWout
echo %line3%
echo.
)
if defined ohook (
echo.
echo.
echo %line2%
echo *** Office Ohook Activation Status ***
echo %line2%
echo.
powershell "write-host -back 'Black' -fore 'Yellow' 'Ohook for permanent Office activation is installed.'; write-host -back 'Black' -fore 'Yellow' 'You can ignore below Office activation status.'"
echo.
)
:casWcon
set winID=0
set verbose=1
if not defined c0ff1ce15 (
if defined osppsvc goto :casWospp
goto :casWend
)
echo %line2%
echo *** Office Status ***
echo %line2%
set "_qr=%_zz7% %wspp% %_zz2% %_zz5%ApplicationID='%o15App%' and PartialProductKey is not null%_zz6% %_zz3% ID %_zz8%"
for /f "tokens=2 delims==" %%# in ('%_qr%') do (
set "chkID=%%#"
call :casWdet "%wspp%" "%wsps%" "%spp_get%"
call :casWout
echo %line3%
echo.
)
set verbose=0
if defined osppsvc goto :casWospp
goto :casWend
:casWospp
if %verbose% EQU 1 (
echo %line2%
echo *** Office Status ***
echo %line2%
)
set "_qr=%_zz7% %ospp% %_zz2% %_zz5%ApplicationID='%o15App%' and PartialProductKey is not null%_zz6% %_zz3% ID %_zz8%"
if defined ospp15 for /f "tokens=2 delims==" %%# in ('%_qr%') do (
set "chkID=%%#"
call :casWdet "%ospp%" "%osps%" "%ospp_get%"
call :casWout
echo %line3%
echo.
)
set "_qr=%_zz7% %ospp% %_zz2% %_zz5%ApplicationID='%o14App%' and PartialProductKey is not null%_zz6% %_zz3% ID %_zz8%"
if defined ospp14 for /f "tokens=2 delims==" %%# in ('%_qr%') do (
set "chkID=%%#"
call :casWdet "%ospp%" "%osps%" "%ospp_get%"
call :casWout
echo %line3%
echo.
)
goto :casWend
:casWpkey
set "_qr=%_zz1% %1 %_zz2% %_zz5%ApplicationID='%2' and PartialProductKey is not null%_zz6% %_zz3% ID %_zz4%"
%_qr% 2>nul | findstr /i ID 1>nul && (set %3=1&set %4=1)
exit /b
:casWdet
for %%# in (%~3) do set "%%#="
if /i %~1==%ospp% for %%# in (DiscoveredKeyManagementServiceMachineIpAddress, KeyManagementServiceLookupDomain, ProductKeyChannel, VLActivationTypeEnabled) do set "%%#="
set "cKmsClient="
set "cTblClient="
set "cAvmClient="
set "ExpireMsg="
set "_xpr="
set "_qr="wmic path %~1 where ID='%chkID%' get %~3 /value" ^| findstr ^="
if %WMI_VBS% NEQ 0 set "_qr=%_csg% %~1 "ID='%chkID%'" "%~3""
for /f "tokens=* delims=" %%# in ('%_qr%') do set "%%#"
set /a _gpr=(GracePeriodRemaining+1440-1)/1440
echo %Description%| findstr /i VOLUME_KMSCLIENT 1>nul && (set cKmsClient=1&set _mTag=Volume)
echo %Description%| findstr /i TIMEBASED_ 1>nul && (set cTblClient=1&set _mTag=Timebased)
echo %Description%| findstr /i VIRTUAL_MACHINE_ACTIVATION 1>nul && (set cAvmClient=1&set _mTag=Automatic VM)
cmd /c exit /b %LicenseStatusReason%
set "LicenseReason=%=ExitCode%"
set "LicenseMsg=Time remaining: %GracePeriodRemaining% minute(s) (%_gpr% day(s))"
if %_gpr% GEQ 1 if %_WSH% EQU 1 (
for /f "tokens=* delims=" %%# in ('%_csx% %GracePeriodRemaining%') do set "_xpr=%%#"
)
if %_gpr% GEQ 1 if %_prsh% EQU 1 if not defined _xpr (
for /f "tokens=* delims=" %%# in ('%_psc% "$([DateTime]::Now.addMinutes(%GracePeriodRemaining%)).ToString('yyyy-MM-dd HH:mm:ss')" 2^>nul') do set "_xpr=%%#"
title Check Activation Status [wmi]
)
if %LicenseStatus% EQU 0 (
set "License=Unlicensed"
set "LicenseMsg="
)
if %LicenseStatus% EQU 1 (
set "License=Licensed"
set "LicenseMsg="
if %GracePeriodRemaining% EQU 0 (
if %winID% EQU 1 (set "ExpireMsg=The machine is permanently activated.") else (set "ExpireMsg=The product is permanently activated.")
) else (
set "LicenseMsg=%_mTag% activation expiration: %GracePeriodRemaining% minute(s) (%_gpr% day(s))"
if defined _xpr set "ExpireMsg=%_mTag% activation will expire %_xpr%"
)
)
if %LicenseStatus% EQU 2 (
set "License=Initial grace period"
if defined _xpr set "ExpireMsg=Initial grace period ends %_xpr%"
)
if %LicenseStatus% EQU 3 (
set "License=Additional grace period (KMS license expired or hardware out of tolerance)"
if defined _xpr set "ExpireMsg=Additional grace period ends %_xpr%"
)
if %LicenseStatus% EQU 4 (
set "License=Non-genuine grace period."
if defined _xpr set "ExpireMsg=Non-genuine grace period ends %_xpr%"
)
if %LicenseStatus% EQU 6 (
set "License=Extended grace period"
if defined _xpr set "ExpireMsg=Extended grace period ends %_xpr%"
)
if %LicenseStatus% EQU 5 (
set "License=Notification"
if "%LicenseReason%"=="C004F200" (set "LicenseMsg=Notification Reason: 0xC004F200 (non-genuine)."
) else if "%LicenseReason%"=="C004F009" (set "LicenseMsg=Notification Reason: 0xC004F009 (grace time expired)."
) else (set "LicenseMsg=Notification Reason: 0x%LicenseReason%"
)
)
if %LicenseStatus% GTR 6 (
set "License=Unknown"
set "LicenseMsg="
)
if not defined cKmsClient exit /b
if %KeyManagementServicePort%==0 set KeyManagementServicePort=1688
set "KmsReg=Registered KMS machine name: %KeyManagementServiceMachine%:%KeyManagementServicePort%"
if "%KeyManagementServiceMachine%"=="" set "KmsReg=Registered KMS machine name: KMS name not available"
if %DiscoveredKeyManagementServiceMachinePort%==0 set DiscoveredKeyManagementServiceMachinePort=1688
set "KmsDns=KMS machine name from DNS: %DiscoveredKeyManagementServiceMachineName%:%DiscoveredKeyManagementServiceMachinePort%"
if "%DiscoveredKeyManagementServiceMachineName%"=="" set "KmsDns=DNS auto-discovery: KMS name not available"
set "_qr="wmic path %~2 get ClientMachineID, KeyManagementServiceHostCaching /value" ^| findstr ^="
if %WMI_VBS% NEQ 0 set "_qr=%_csg% %~2 "ClientMachineID, KeyManagementServiceHostCaching""
for /f "tokens=* delims=" %%# in ('%_qr%') do set "%%#"
if /i %KeyManagementServiceHostCaching%==True (set KeyManagementServiceHostCaching=Enabled) else (set KeyManagementServiceHostCaching=Disabled)
if %winbuild% LSS 9200 exit /b
if /i %~1==%ospp% exit /b
if "%KeyManagementServiceLookupDomain%"=="" set "KeyManagementServiceLookupDomain="
if %VLActivationTypeEnabled% EQU 3 (
set VLActivationType=Token
) else if %VLActivationTypeEnabled% EQU 2 (
set VLActivationType=KMS
) else if %VLActivationTypeEnabled% EQU 1 (
set VLActivationType=AD
) else (
set VLActivationType=All
)
if %winbuild% LSS 9600 exit /b
if "%DiscoveredKeyManagementServiceMachineIpAddress%"=="" set "DiscoveredKeyManagementServiceMachineIpAddress=not available"
exit /b
:casWout
echo.
echo Name: %Name%
echo Description: %Description%
echo Activation ID: %ID%
echo Extended PID: %ProductKeyID%
if defined ProductKeyChannel echo Product Key Channel: %ProductKeyChannel%
echo Partial Product Key: %PartialProductKey%
echo License Status: %License%
if defined LicenseMsg echo %LicenseMsg%
if not %LicenseStatus%==0 if not %EvaluationEndDate:~0,8%==16010101 echo Evaluation End Date: %EvaluationEndDate:~0,4%-%EvaluationEndDate:~4,2%-%EvaluationEndDate:~6,2% %EvaluationEndDate:~8,2%:%EvaluationEndDate:~10,2% UTC
if not defined cKmsClient (
if defined ExpireMsg echo.&echo. %ExpireMsg%
exit /b
)
if defined VLActivationTypeEnabled echo Configured Activation Type: %VLActivationType%
echo.
if not %LicenseStatus%==1 (
echo Please activate the product in order to update KMS client information values.
exit /b
)
echo Most recent activation information:
echo Key Management Service client information
echo. Client Machine ID (CMID): %ClientMachineID%
echo. %KmsDns%
echo. %KmsReg%
if defined DiscoveredKeyManagementServiceMachineIpAddress echo. KMS machine IP address: %DiscoveredKeyManagementServiceMachineIpAddress%
echo. KMS machine extended PID: %KeyManagementServiceProductKeyID%
echo. Activation interval: %VLActivationInterval% minutes
echo. Renewal interval: %VLRenewalInterval% minutes
echo. K.M.S host caching: %KeyManagementServiceHostCaching%
if defined KeyManagementServiceLookupDomain echo. KMS SRV record lookup domain: %KeyManagementServiceLookupDomain%
if defined ExpireMsg echo.&echo. %ExpireMsg%
exit /b
:casWend
if %_Identity% EQU 1 if %_prsh% EQU 1 (
echo %line2%
echo *** Office vNext Status ***
echo %line2%
setlocal EnableDelayedExpansion
%_psc% "$f=[IO.File]::ReadAllText('!_batp!') -split ':vNextDiag\:.*';iex ($f[1])"
title Check Activation Status [wmi]
echo %line3%
echo.
)
echo.
echo Press any key to exit.
pause >nul
exit /b
:vNextDiag:
function PrintModePerPridFromRegistry
{
$vNextRegkey = "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext"
$vNextPrids = Get-Item -Path $vNextRegkey -ErrorAction Ignore | Select-Object -ExpandProperty 'property' | Where-Object -FilterScript {$_.ToLower() -like "*retail" -or $_.ToLower() -like "*volume"}
If ($vNextPrids -Eq $null)
{
Write-Host "No registry keys found."
Return
}
$vNextPrids | ForEach `
{
$mode = (Get-ItemProperty -Path $vNextRegkey -Name $_).$_
Switch ($mode)
{
2 { $mode = "vNext"; Break }
3 { $mode = "Device"; Break }
Default { $mode = "Legacy"; Break }
}
Write-Host $_ = $mode
}
}
function PrintSharedComputerLicensing
{
$scaRegKey = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration"
$scaValue = Get-ItemProperty -Path $scaRegKey -ErrorAction Ignore | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction Ignore
$scaRegKey2 = "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing"
$scaValue2 = Get-ItemProperty -Path $scaRegKey2 -ErrorAction Ignore | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction Ignore
$scaPolicyKey = "HKLM:\SOFTWARE\Policies\Microsoft\Office\16.0\Common\Licensing"
$scaPolicyValue = Get-ItemProperty -Path $scaPolicyKey -ErrorAction Ignore | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction Ignore
If ($scaValue -Eq $null -And $scaValue2 -Eq $null -And $scaPolicyValue -Eq $null)
{
Write-Host "No registry keys found."
Return
}
$scaModeValue = $scaValue -Or $scaValue2 -Or $scaPolicyValue
If ($scaModeValue -Eq 0)
{
$scaMode = "Disabled"
}
If ($scaModeValue -Eq 1)
{
$scaMode = "Enabled"
}
Write-Host "SharedComputerLicensing" = $scaMode
Write-Host
$tokenFiles = $null
$tokenPath = "${env:LOCALAPPDATA}\Microsoft\Office\16.0\Licensing"
If (Test-Path $tokenPath)
{
$tokenFiles = Get-ChildItem -Path $tokenPath -Recurse -File -Filter "*authString*"
}
If ($tokenFiles.length -Eq 0)
{
Write-Host "No tokens found."
Return
}
$tokenFiles | ForEach `
{
$tokenParts = (Get-Content -Encoding Unicode -Path $_.FullName).Split('_')
$output = [PSCustomObject] `
@{
ACID = $tokenParts[0];
User = $tokenParts[3]
NotBefore = $tokenParts[4];
NotAfter = $tokenParts[5];
} | ConvertTo-Json
Write-Host $output
}
}
function PrintLicensesInformation
{
Param(
[ValidateSet("NUL", "Device")]
[String]$mode
)
If ($mode -Eq "NUL")
{
$licensePath = "${env:LOCALAPPDATA}\Microsoft\Office\Licenses"
}
ElseIf ($mode -Eq "Device")
{
$licensePath = "${env:PROGRAMDATA}\Microsoft\Office\Licenses"
}
$licenseFiles = $null
If (Test-Path $licensePath)
{
$licenseFiles = Get-ChildItem -Path $licensePath -Recurse -File
}
If ($licenseFiles.length -Eq 0)
{
Write-Host "No licenses found."
Return
}
$licenseFiles | ForEach `
{
$license = (Get-Content -Encoding Unicode $_.FullName | ConvertFrom-Json).License
$decodedLicense = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($license)) | ConvertFrom-Json
$licenseType = $decodedLicense.LicenseType
If ($null -Ne $decodedLicense.ExpiresOn)
{
$expiry = [DateTime]::Parse($decodedLicense.ExpiresOn, $null, 48)
}
Else
{
$expiry = New-Object DateTime
}
$licenseState = $null
If ((Get-Date) -Gt (Get-Date $decodedLicense.MetaData.NotAfter))
{
$licenseState = "RFM"
}
ElseIf ((Get-Date) -Lt (Get-Date $expiry))
{
$licenseState = "Licensed"
}
Else
{
$licenseState = "Grace"
}
if ($mode -Eq "NUL")
{
$output = [PSCustomObject] `
@{
Version = $_.Directory.Name
Type = "User|${licenseType}";
Product = $decodedLicense.ProductReleaseId;
Acid = $decodedLicense.Acid;
LicenseState = $licenseState;
EntitlementStatus = $decodedLicense.Status;
EntitlementExpiration = $decodedLicense.ExpiresOn;
ReasonCode = $decodedLicense.ReasonCode;
NotBefore = $decodedLicense.Metadata.NotBefore;
NotAfter = $decodedLicense.Metadata.NotAfter;
NextRenewal = $decodedLicense.Metadata.RenewAfter;
TenantId = $decodedLicense.Metadata.TenantId;
} | ConvertTo-Json
}
ElseIf ($mode -Eq "Device")
{
$output = [PSCustomObject] `
@{
Version = $_.Directory.Name
Type = "Device|${licenseType}";
Product = $decodedLicense.ProductReleaseId;
Acid = $decodedLicense.Acid;
DeviceId = $decodedLicense.Metadata.DeviceId;
LicenseState = $licenseState;
EntitlementStatus = $decodedLicense.Status;
EntitlementExpiration = $decodedLicense.ExpiresOn;
ReasonCode = $decodedLicense.ReasonCode;
NotBefore = $decodedLicense.Metadata.NotBefore;
NotAfter = $decodedLicense.Metadata.NotAfter;
NextRenewal = $decodedLicense.Metadata.RenewAfter;
TenantId = $decodedLicense.Metadata.TenantId;
} | ConvertTo-Json
}
Write-Output $output
}
}
Write-Host
Write-Host "========== Mode per ProductReleaseId =========="
Write-Host
PrintModePerPridFromRegistry
Write-Host
Write-Host "========== Shared Computer Licensing =========="
Write-Host
PrintSharedComputerLicensing
Write-Host
Write-Host "========== vNext licenses =========="
Write-Host
PrintLicensesInformation -Mode "NUL"
Write-Host
Write-Host "========== Device licenses =========="
Write-Host
PrintLicensesInformation -Mode "Device"
:vNextDiag:
::===================================================
:: Leave empty line below

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,12 @@
@set masver=2.6 @set masver=2.6
@setlocal DisableDelayedExpansion
@echo off @echo off
::============================================================================ ::============================================================================
:: ::
:: This script is a part of 'Microsoft-Activation-Scripts' (MAS) project.
::
:: Homepage: mass grave[.]dev :: Homepage: mass grave[.]dev
:: Email: windowsaddict@protonmail.com :: Email: mas.help@outlook.com
:: ::
::============================================================================ ::============================================================================
@@ -17,26 +14,32 @@
::======================================================================================================================================== ::========================================================================================================================================
:: Set Path variable, it helps if it is misconfigured in the system :: Set Environment variables, it helps if they are misconfigured in the system
set "PATH=%SystemRoot%\System32;%SystemRoot%\System32\wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" setlocal EnableExtensions
setlocal DisableDelayedExpansion
set "PathExt=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
set "SysPath=%SystemRoot%\System32"
set "Path=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\"
if exist "%SystemRoot%\Sysnative\reg.exe" ( if exist "%SystemRoot%\Sysnative\reg.exe" (
set "PATH=%SystemRoot%\Sysnative;%SystemRoot%\Sysnative\wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%PATH%" set "SysPath=%SystemRoot%\Sysnative"
set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%"
) )
:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows set "ComSpec=%SysPath%\cmd.exe"
:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules"
set "_cmdf=%~f0" set "_cmdf=%~f0"
for %%# in (%*) do ( for %%# in (%*) do (
if /i "%%#"=="r1" set r1=1 if /i "%%#"=="r1" set r1=1
if /i "%%#"=="r2" set r2=1 if /i "%%#"=="r2" set r2=1
if /i "%%#"=="-qedit" (
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "1" /f %nul1%
rem check the code below admin elevation to understand why it's here
)
) )
:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows
:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows
if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 ( if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1" start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1"
@@ -64,10 +67,10 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Help - %mas%troubleshoot.html echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 10 ping 127.0.0.1 -n 20
) )
cls cls
@@ -76,9 +79,13 @@ cls
pushd "%~dp0" pushd "%~dp0"
>nul findstr /v "$" "%~nx0" && ( >nul findstr /v "$" "%~nx0" && (
echo: echo:
echo Error: Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
ping 127.0.0.1 -n 6 >nul echo:
echo Help - %mas%troubleshoot
echo:
echo:
ping 127.0.0.1 -n 20 >nul
popd popd
exit /b exit /b
) )
@@ -92,6 +99,7 @@ title Extract $OEM$ Folder %masver%
set _args= set _args=
set _elev= set _elev=
set _unattended=0
set _args=%* set _args=%*
if defined _args set _args=%_args:"=% if defined _args set _args=%_args:"=%
@@ -106,35 +114,7 @@ set "nul2=2>nul"
set "nul6=2^>nul" set "nul6=2^>nul"
set "nul=>nul 2>&1" set "nul=>nul 2>&1"
set psc=powershell.exe call :dk_setvar
set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _NCS=1
if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
if %_NCS% EQU 1 (
for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a"
set "Red="41;97m""
set "Gray="100;97m""
set "Green="42;97m""
set "Blue="44;97m""
set "_White="40;37m""
set "_Green="40;92m""
set "_Yellow="40;93m""
) else (
set "Red="Red" "white""
set "Gray="Darkgray" "white""
set "Green="DarkGreen" "white""
set "Blue="Blue" "white""
set "_White="Black" "Gray""
set "_Green="Black" "Green""
set "_Yellow="Black" "Yellow""
)
set "nceline=echo: &echo ==== ERROR ==== &echo:"
set "eline=echo: &call :ex_color %Red% "==== ERROR ====" &echo:"
::======================================================================================================================================== ::========================================================================================================================================
@@ -145,12 +125,6 @@ echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equiva
goto done2 goto done2
) )
for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" (
%nceline%
echo Unable to find powershell.exe in the system.
goto done2
)
::======================================================================================================================================== ::========================================================================================================================================
:: Fix special characters limitation in path name :: Fix special characters limitation in path name
@@ -162,6 +136,8 @@ set "_batf=%~f0"
set "_batp=%_batf:'=''%" set "_batp=%_batf:'=''%"
set _PSarg="""%~f0""" -el %_args% set _PSarg="""%~f0""" -el %_args%
set _PSarg=%_PSarg:'=''%
set "_ttemp=%userprofile%\AppData\Local\Temp" set "_ttemp=%userprofile%\AppData\Local\Temp"
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
@@ -181,10 +157,36 @@ goto done2
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PowerShellTest: $ExecutionContext.SessionState.LanguageMode :PowerShellTest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PowerShellTest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
call :dk_color %Blue% "Check if your antivirus is blocking the script."
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto done2
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
if not defined _elev %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b if not defined _elev %psc% "start cmd.exe -arg '/c \"!_PSarg!\"' -verb runas" && exit /b
%eline% %eline%
echo This script needs admin rights. echo This script needs admin rights.
echo To do so, right click on this script and select 'Run as administrator'. echo To do so, right click on this script and select 'Run as administrator'.
@@ -193,18 +195,45 @@ goto done2
::======================================================================================================================================== ::========================================================================================================================================
:: This code disables QuickEdit for this cmd.exe session only without making permanent changes to the registry :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
:: It is added because clicking on the script window pauses the operation and leads to the confusion that script stopped due to an error
for %%# in (%_args%) do (if /i "%%#"=="-qedit" set quedit=1) if %winbuild% GEQ 17763 (
set terminal=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% || if not defined quedit ( ) else (
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "0" /f %nul1% set terminal=
start cmd.exe /c ""!_batf!" %_args% -qedit"
rem quickedit reset code is added at the starting of the script instead of here because it takes time to reflect in some cases
exit /b
) )
:: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal (
%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal=
)
if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
if defined terminal (
set "launchcmd=start conhost.exe %psc%"
) else (
set "launchcmd=%psc%"
)
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE
::======================================================================================================================================== ::========================================================================================================================================
:: Check for updates :: Check for updates
@@ -219,18 +248,19 @@ if not [%%#]==[] (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.6
if defined old ( if defined old (
echo ________________________________________________ echo ________________________________________________
%eline% %eline%
echo You are running outdated version MAS %masver% echo Version %masver% of MAS is outdated.
echo ________________________________________________ echo ________________________________________________
echo: echo:
if not %_unattended%==1 (
echo [1] Get Latest MAS echo [1] Get Latest MAS
echo [0] Continue Anyway echo [0] Continue Anyway
echo: echo:
call :ex_color %_Green% "Enter a menu option in the Keyboard [1,0] :" call :dk_color %_Green% "Enter a menu option in the Keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b)
) )
cls )
::======================================================================================================================================== ::========================================================================================================================================
@@ -255,7 +285,7 @@ setlocal EnableDelayedExpansion
::======================================================================================================================================== ::========================================================================================================================================
mode con cols=78 lines=30 if not defined terminal mode 78, 30
if exist "!desktop!\$OEM$\" ( if exist "!desktop!\$OEM$\" (
echo _____________________________________________________ echo _____________________________________________________
@@ -296,7 +326,7 @@ goto done2
:Menu :Menu
cls cls
mode con cols=78 lines=30 if not defined terminal mode 78, 30
echo: echo:
echo: echo:
echo: echo:
@@ -315,16 +345,16 @@ echo: [7] KMS38 ^(Windows^) ^+ Ohook ^(Office^)
echo: [8] KMS38 ^(Windows^) ^+ Online KMS ^(Office^) echo: [8] KMS38 ^(Windows^) ^+ Online KMS ^(Office^)
echo: [9] Online KMS ^(Windows^) ^+ Ohook ^(Office^) echo: [9] Online KMS ^(Windows^) ^+ Ohook ^(Office^)
echo: echo:
call :ex_color2 %_White% " [R] " %_Green% "ReadMe" call :dk_color2 %_White% " [R] " %_Green% "ReadMe"
echo: [0] Exit echo: [0] Exit
echo: ________________________________________________________ echo: ________________________________________________________
echo: echo:
call :ex_color2 %_White% " " %_Green% "Enter a menu option in the Keyboard :" call :dk_color2 %_White% " " %_Green% "Enter a menu option in the Keyboard :"
choice /C:123456789R0 /N choice /C:123456789R0 /N
set _erl=%errorlevel% set _erl=%errorlevel%
if %_erl%==11 exit /b if %_erl%==11 exit /b
if %_erl%==10 start %mas%oem-folder.html &goto :Menu if %_erl%==10 start %mas%oem-folder &goto :Menu
if %_erl%==9 goto:kms_ohook if %_erl%==9 goto:kms_ohook
if %_erl%==8 goto:kms38_kms if %_erl%==8 goto:kms38_kms
if %_erl%==7 goto:kms38_ohook if %_erl%==7 goto:kms38_ohook
@@ -450,7 +480,7 @@ goto done
fltmc >nul || exit /b fltmc >nul || exit /b
call "%~dp0Online_KMS_Activation.cmd" /KMS-ActAndRenewalTask /KMS-WindowsOffice call "%~dp0Online_KMS_Activation.cmd" /K-WindowsOffice
cd \ cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
@@ -525,7 +555,7 @@ call "%~dp0HWID_Activation.cmd" /HWID
endlocal endlocal
setlocal setlocal
call "%~dp0Online_KMS_Activation.cmd" /KMS-ActAndRenewalTask /KMS-Office call "%~dp0Online_KMS_Activation.cmd" /K-Office
endlocal endlocal
cd \ cd \
@@ -601,7 +631,7 @@ call "%~dp0KMS38_Activation.cmd" /KMS38
endlocal endlocal
setlocal setlocal
call "%~dp0Online_KMS_Activation.cmd" /KMS-ActAndRenewalTask /KMS-Office call "%~dp0Online_KMS_Activation.cmd" /K-Office
endlocal endlocal
cd \ cd \
@@ -635,7 +665,7 @@ goto done
fltmc >nul || exit /b fltmc >nul || exit /b
setlocal setlocal
call "%~dp0Online_KMS_Activation.cmd" /KMS-ActAndRenewalTask /KMS-Windows call "%~dp0Online_KMS_Activation.cmd" /K-Windows
endlocal endlocal
setlocal setlocal
@@ -658,8 +688,8 @@ goto :done2
echo ______________________________________________________________ echo ______________________________________________________________
echo: echo:
call :ex_color %Blue% "%oem%" call :dk_color %Blue% "%oem%"
call :ex_color %Green% "$OEM$ folder is successfully created on the Desktop." call :dk_color %Green% "$OEM$ folder is successfully created on the Desktop."
echo "%oem%" | find /i "38" %nul% && ( echo "%oem%" | find /i "38" %nul% && (
echo: echo:
echo To KMS38 activate Server Cor/Acor editions ^(No GUI Versions^), echo To KMS38 activate Server Cor/Acor editions ^(No GUI Versions^),
@@ -670,8 +700,65 @@ echo ______________________________________________________________
:done2 :done2
echo: echo:
call :ex_color %_Yellow% "Press any key to exit..." if defined fixes (
call :dk_color2 %Blue% "Press [1] To Open Troubleshoot Page " %Gray% " Press [0] To Ignore"
choice /C:10 /N
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#))
)
if defined terminal (
call :dk_color %_Yellow% "Press 0 key to %_exitmsg%..."
choice /c 0 /n
) else (
call :dk_color %_Yellow% "Press any key to %_exitmsg%..."
pause %nul1% pause %nul1%
)
exit /b
::========================================================================================================================================
:: Set variables
:dk_setvar
set psc=powershell.exe
set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _NCS=1
if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
if %_NCS% EQU 1 (
for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a"
set "Red="41;97m""
set "Gray="100;97m""
set "Green="42;97m""
set "Blue="44;97m""
set "_Red="40;91m""
set "_White="40;37m""
set "_Green="40;92m""
set "_Yellow="40;93m""
) else (
set "Red="Red" "white""
set "Gray="Darkgray" "white""
set "Green="DarkGreen" "white""
set "Blue="Blue" "white""
set "_Red="Black" "Red""
set "_White="Black" "Gray""
set "_Green="Black" "Green""
set "_Yellow="Black" "Yellow""
)
set "nceline=echo: &echo ==== ERROR ==== &echo:"
set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:"
if %~z0 GEQ 200000 (
set "_exitmsg=Go back"
set "_fixmsg=Go back to Main Menu, select Troubleshoot and run Fix Licensing option."
) else (
set "_exitmsg=Exit"
set "_fixmsg=In MAS folder, run Troubleshoot script and select Fix Licensing option."
)
exit /b exit /b
::======================================================================================================================================== ::========================================================================================================================================
@@ -685,7 +772,7 @@ exit /b
::======================================================================================================================================== ::========================================================================================================================================
:ex_color :dk_color
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
@@ -694,7 +781,7 @@ if not exist %psc% (echo %~3) else (%psc% write-host -back '%1' -fore '%2' '%3')
) )
exit /b exit /b
:ex_color2 :dk_color2
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m

View File

@@ -1,15 +1,12 @@
@set masver=2.6 @set masver=2.6
@setlocal DisableDelayedExpansion
@echo off @echo off
::============================================================================ ::============================================================================
:: ::
:: This script is a part of 'Microsoft-Activation-Scripts' (MAS) project.
::
:: Homepage: mass grave[.]dev :: Homepage: mass grave[.]dev
:: Email: windowsaddict@protonmail.com :: Email: mas.help@outlook.com
:: ::
::============================================================================ ::============================================================================
@@ -17,26 +14,32 @@
::======================================================================================================================================== ::========================================================================================================================================
:: Set Path variable, it helps if it is misconfigured in the system :: Set Environment variables, it helps if they are misconfigured in the system
set "PATH=%SystemRoot%\System32;%SystemRoot%\System32\wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" setlocal EnableExtensions
setlocal DisableDelayedExpansion
set "PathExt=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
set "SysPath=%SystemRoot%\System32"
set "Path=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\"
if exist "%SystemRoot%\Sysnative\reg.exe" ( if exist "%SystemRoot%\Sysnative\reg.exe" (
set "PATH=%SystemRoot%\Sysnative;%SystemRoot%\Sysnative\wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%PATH%" set "SysPath=%SystemRoot%\Sysnative"
set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%"
) )
:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows set "ComSpec=%SysPath%\cmd.exe"
:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules"
set "_cmdf=%~f0" set "_cmdf=%~f0"
for %%# in (%*) do ( for %%# in (%*) do (
if /i "%%#"=="r1" set r1=1 if /i "%%#"=="r1" set r1=1
if /i "%%#"=="r2" set r2=1 if /i "%%#"=="r2" set r2=1
if /i "%%#"=="-qedit" (
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "1" /f %nul1%
rem check the code below admin elevation to understand why it's here
)
) )
:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows
:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows
if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 ( if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1" start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1"
@@ -64,10 +67,10 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Help - %mas%troubleshoot.html echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 10 ping 127.0.0.1 -n 20
) )
cls cls
@@ -76,9 +79,13 @@ cls
pushd "%~dp0" pushd "%~dp0"
>nul findstr /v "$" "%~nx0" && ( >nul findstr /v "$" "%~nx0" && (
echo: echo:
echo Error: Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
ping 127.0.0.1 -n 6 >nul echo:
echo Help - %mas%troubleshoot
echo:
echo:
ping 127.0.0.1 -n 20 >nul
popd popd
exit /b exit /b
) )
@@ -92,6 +99,7 @@ title Troubleshoot %masver%
set _args= set _args=
set _elev= set _elev=
set _unattended=0
set _args=%* set _args=%*
if defined _args set _args=%_args:"=% if defined _args set _args=%_args:"=%
@@ -106,20 +114,8 @@ set "nul2=2>nul"
set "nul6=2^>nul" set "nul6=2^>nul"
set "nul=>nul 2>&1" set "nul=>nul 2>&1"
set psc=powershell.exe call :dk_setvar
set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _NCS=1
if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
call :_colorprep
set "nceline=echo: &echo ==== ERROR ==== &echo:"
set "eline=echo: &call :_color %Red% "==== ERROR ====" &echo:"
set "line=_________________________________________________________________________________________________" set "line=_________________________________________________________________________________________________"
if %~z0 GEQ 200000 (set "_exitmsg=Go back") else (set "_exitmsg=Exit")
::======================================================================================================================================== ::========================================================================================================================================
@@ -127,13 +123,7 @@ if %winbuild% LSS 7600 (
%nceline% %nceline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalent. echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalent.
goto at_done goto dk_done
)
for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" (
%nceline%
echo Unable to find powershell.exe in the system.
goto at_done
) )
::======================================================================================================================================== ::========================================================================================================================================
@@ -147,6 +137,7 @@ set "_batf=%~f0"
set "_batp=%_batf:'=''%" set "_batp=%_batf:'=''%"
set _PSarg="""%~f0""" -el %_args% set _PSarg="""%~f0""" -el %_args%
set _PSarg=%_PSarg:'=''%
set "_ttemp=%userprofile%\AppData\Local\Temp" set "_ttemp=%userprofile%\AppData\Local\Temp"
@@ -156,41 +147,94 @@ setlocal EnableDelayedExpansion
echo "!_batf!" | find /i "!_ttemp!" %nul1% && ( echo "!_batf!" | find /i "!_ttemp!" %nul1% && (
if /i not "!_work!"=="!_ttemp!" ( if /i not "!_work!"=="!_ttemp!" (
%nceline% %eline%
echo Script is launched from the temp folder, echo Script is launched from the temp folder,
echo Most likely you are running the script directly from the archive file. echo Most likely you are running the script directly from the archive file.
echo: echo:
echo Extract the archive file and launch the script from the extracted folder. echo Extract the archive file and launch the script from the extracted folder.
goto at_done goto dk_done
) )
) )
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PowerShellTest: $ExecutionContext.SessionState.LanguageMode :PowerShellTest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PowerShellTest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
call :dk_color %Blue% "Check if your antivirus is blocking the script."
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto dk_done
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
if not defined _elev %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b if not defined _elev %psc% "start cmd.exe -arg '/c \"!_PSarg!\"' -verb runas" && exit /b
%nceline% %eline%
echo This script needs admin rights. echo This script needs admin rights.
echo To do so, right click on this script and select 'Run as administrator'. echo To do so, right click on this script and select 'Run as administrator'.
goto at_done goto dk_done
) )
::======================================================================================================================================== ::========================================================================================================================================
:: This code disables QuickEdit for this cmd.exe session only without making permanent changes to the registry :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
:: It is added because clicking on the script window pauses the operation and leads to the confusion that script stopped due to an error
for %%# in (%_args%) do (if /i "%%#"=="-qedit" set quedit=1) if %winbuild% GEQ 17763 (
set terminal=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% || if not defined quedit ( ) else (
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "0" /f %nul1% set terminal=
start cmd.exe /c ""!_batf!" %_args% -qedit"
rem quickedit reset code is added at the starting of the script instead of here because it takes time to reflect in some cases
exit /b
) )
:: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal (
%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal=
)
if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
if defined terminal (
set "launchcmd=start conhost.exe %psc%"
) else (
set "launchcmd=%psc%"
)
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE
::======================================================================================================================================== ::========================================================================================================================================
:: Check for updates :: Check for updates
@@ -205,18 +249,19 @@ if not [%%#]==[] (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.6
if defined old ( if defined old (
echo ________________________________________________ echo ________________________________________________
%eline% %eline%
echo You are running outdated version MAS %masver% echo Version %masver% of MAS is outdated.
echo ________________________________________________ echo ________________________________________________
echo: echo:
if not %_unattended%==1 (
echo [1] Get Latest MAS echo [1] Get Latest MAS
echo [0] Continue Anyway echo [0] Continue Anyway
echo: echo:
call :_color %_Green% "Enter a menu option in the Keyboard [1,0] :" call :dk_color %_Green% "Enter a menu option in the Keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b)
) )
cls )
::======================================================================================================================================== ::========================================================================================================================================
@@ -231,7 +276,7 @@ if not defined desktop for /f "delims=" %%a in ('%psc% "& {write-host $([Environ
if not defined desktop ( if not defined desktop (
%eline% %eline%
echo Desktop location was not detected, aborting... echo Desktop location was not detected, aborting...
goto at_done goto dk_done
) )
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
@@ -243,7 +288,7 @@ setlocal EnableDelayedExpansion
cls cls
color 07 color 07
title Troubleshoot %masver% title Troubleshoot %masver%
mode con cols=77 lines=30 if not defined terminal mode 77, 30
echo: echo:
echo: echo:
@@ -251,7 +296,7 @@ echo:
echo: echo:
echo: _______________________________________________________________ echo: _______________________________________________________________
echo: echo:
call :_color2 %_White% " [1] " %_Green% "Help" call :dk_color2 %_White% " [1] " %_Green% "Help"
echo: ___________________________________________________ echo: ___________________________________________________
echo: echo:
echo: [2] Dism RestoreHealth echo: [2] Dism RestoreHealth
@@ -265,12 +310,12 @@ echo:
echo: [0] %_exitmsg% echo: [0] %_exitmsg%
echo: _______________________________________________________________ echo: _______________________________________________________________
echo: echo:
call :_color2 %_White% " " %_Green% "Enter a menu option in the Keyboard :" call :dk_color2 %_White% " " %_Green% "Enter a menu option in the Keyboard :"
choice /C:1234560 /N choice /C:1234560 /N
set _erl=%errorlevel% set _erl=%errorlevel%
if %_erl%==7 exit /b if %_erl%==7 exit /b
if %_erl%==6 start %mas%fix-wpa-registry.html &goto at_menu if %_erl%==6 start %mas%fix-wpa-registry &goto at_menu
if %_erl%==5 goto:retokens if %_erl%==5 goto:retokens
if %_erl%==4 goto:fixwmi if %_erl%==4 goto:fixwmi
if %_erl%==3 goto:sfcscan if %_erl%==3 goto:sfcscan
@@ -283,7 +328,7 @@ goto :at_menu
:dism_rest :dism_rest
cls cls
mode 98, 30 if not defined terminal mode 98, 30
title Dism /English /Online /Cleanup-Image /RestoreHealth title Dism /English /Online /Cleanup-Image /RestoreHealth
if %winbuild% LSS 9200 ( if %winbuild% LSS 9200 (
@@ -302,7 +347,7 @@ echo:
if defined _int ( if defined _int (
echo Checking Internet Connection [Connected] echo Checking Internet Connection [Connected]
) else ( ) else (
call :_color2 %_White% " " %Red% "Checking Internet Connection [Not connected]" call :dk_color2 %_White% " " %Red% "Checking Internet Connection [Not connected]"
) )
echo %line% echo %line%
@@ -313,8 +358,8 @@ echo %line%
echo: echo:
echo Notes: echo Notes:
echo: echo:
call :_color2 %_White% " - " %Gray% "Make sure the Internet is connected." call :dk_color2 %_White% " - " %Gray% "Make sure the Internet is connected."
call :_color2 %_White% " - " %Gray% "Make sure the Windows update is properly working." call :dk_color2 %_White% " - " %Gray% "Make sure the Windows update is properly working."
echo: echo:
echo %line% echo %line%
echo: echo:
@@ -322,22 +367,29 @@ choice /C:09 /N /M "> [9] Continue [0] Go back : "
if %errorlevel%==1 goto at_menu if %errorlevel%==1 goto at_menu
cls cls
mode 110, 30 if not defined terminal mode 110, 30
for /f %%a in ('%psc% "(Get-Date).ToString('yyyyMMdd-HHmmssfff')"') do set _time=%%a
%psc% Stop-Service TrustedInstaller -force %nul% %psc% Stop-Service TrustedInstaller -force %nul%
set _time= copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "%SystemRoot%\logs\cbs\backup_cbs_%_time%.log" %nul%
for /f %%a in ('%psc% "Get-Date -format HH_mm_ss"') do set _time=%%a copy /y /b "%SystemRoot%\logs\DISM\dism.log" "%SystemRoot%\logs\DISM\backup_dism_%_time%.log" %nul%
del /f /q "%SystemRoot%\logs\cbs\cbs.log" %nul%
del /f /q "%SystemRoot%\logs\DISM\dism.log" %nul%
echo: echo:
echo Applying the command, echo Applying the command,
echo dism /english /online /cleanup-image /restorehealth echo dism /english /online /cleanup-image /restorehealth
dism /english /online /cleanup-image /restorehealth dism /english /online /cleanup-image /restorehealth
%psc% Stop-Service TrustedInstaller -force %nul% timeout /t 5 %nul1%
copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "%SystemRoot%\logs\cbs\cbs_%_time%.log" %nul%
copy /y /b "%SystemRoot%\logs\DISM\dism.log" "%SystemRoot%\logs\DISM\dism_%_time%.log" %nul%
if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul% if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul%
call :compresslog cbs\cbs_%_time%.log AT_Logs\RHealth_CBS %nul%
call :compresslog cbs\CBS.log RHealth_CBS %nul% call :compresslog DISM\dism_%_time%.log AT_Logs\RHealth_DISM %nul%
call :compresslog DISM\dism.log RHealth_DISM %nul%
if not exist "!desktop!\AT_Logs\RHealth_CBS_%_time%.cab" ( if not exist "!desktop!\AT_Logs\RHealth_CBS_%_time%.cab" (
copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "!desktop!\AT_Logs\RHealth_CBS_%_time%.log" %nul% copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "!desktop!\AT_Logs\RHealth_CBS_%_time%.log" %nul%
@@ -348,7 +400,7 @@ copy /y /b "%SystemRoot%\logs\DISM\dism.log" "!desktop!\AT_Logs\RHealth_DISM_%_t
) )
echo: echo:
call :_color %Gray% "CBS and DISM logs are copied to the AT_Logs folder on the dekstop." call :dk_color %Gray% "CBS and DISM logs are copied to the AT_Logs folder on the desktop."
goto :at_back goto :at_back
::======================================================================================================================================== ::========================================================================================================================================
@@ -356,7 +408,7 @@ goto :at_back
:sfcscan :sfcscan
cls cls
mode 98, 30 if not defined terminal mode 98, 30
title sfc /scannow title sfc /scannow
echo: echo:
@@ -375,27 +427,30 @@ choice /C:09 /N /M "> [9] Continue [0] Go back : "
if %errorlevel%==1 goto at_menu if %errorlevel%==1 goto at_menu
cls cls
for /f %%a in ('%psc% "(Get-Date).ToString('yyyyMMdd-HHmmssfff')"') do set _time=%%a
%psc% Stop-Service TrustedInstaller -force %nul% %psc% Stop-Service TrustedInstaller -force %nul%
set _time= copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "%SystemRoot%\logs\cbs\backup_cbs_%_time%.log" %nul%
for /f %%a in ('%psc% "Get-Date -format HH_mm_ss"') do set _time=%%a del /f /q "%SystemRoot%\logs\cbs\cbs.log" %nul%
echo: echo:
echo Applying the command, echo Applying the command,
echo sfc /scannow echo sfc /scannow
sfc /scannow sfc /scannow
%psc% Stop-Service TrustedInstaller -force %nul% timeout /t 5 %nul1%
copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "%SystemRoot%\logs\cbs\cbs_%_time%.log" %nul%
if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul% if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul%
call :compresslog cbs\cbs_%_time%.log AT_Logs\SFC_CBS %nul%
call :compresslog cbs\CBS.log SFC_CBS %nul%
if not exist "!desktop!\AT_Logs\SFC_CBS_%_time%.cab" ( if not exist "!desktop!\AT_Logs\SFC_CBS_%_time%.cab" (
copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "!desktop!\AT_Logs\SFC_CBS_%_time%.log" %nul% copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "!desktop!\AT_Logs\SFC_CBS_%_time%.log" %nul%
) )
echo: echo:
call :_color %Gray% "CBS log is copied to the AT_Logs folder on the dekstop." call :dk_color %Gray% "CBS log is copied to the AT_Logs folder on the desktop."
goto :at_back goto :at_back
::======================================================================================================================================== ::========================================================================================================================================
@@ -403,7 +458,7 @@ goto :at_back
:retokens :retokens
cls cls
mode con cols=125 lines=32 if not defined terminal mode 125, 32
%psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}" %psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}"
title Fix Licensing ^(ClipSVC ^+ Office vNext ^+ SPP ^+ OSPP^) title Fix Licensing ^(ClipSVC ^+ Office vNext ^+ SPP ^+ OSPP^)
@@ -422,7 +477,7 @@ echo - Clear ClipSVC, Office vNext, SPP and OSPP licenses
echo - Fix SPP permissions of tokens folder and registries echo - Fix SPP permissions of tokens folder and registries
echo - Trigger the repair option for Office. echo - Trigger the repair option for Office.
echo: echo:
call :_color2 %_White% " - " %Red% "Apply it only when it is necessary." call :dk_color2 %_White% " - " %Red% "Apply it only when it is necessary."
echo: echo:
echo %line% echo %line%
echo: echo:
@@ -439,7 +494,7 @@ cls
echo: echo:
echo %line% echo %line%
echo: echo:
call :_color %Blue% "Rebuilding ClipSVC Licences" call :dk_color %Blue% "Rebuilding ClipSVC Licences"
echo: echo:
if %winbuild% LSS 10240 ( if %winbuild% LSS 10240 (
@@ -468,7 +523,7 @@ if %winbuild% LEQ 10240 (
echo [Successful] echo [Successful]
) else ( ) else (
if exist "%ProgramData%\Microsoft\Windows\ClipSVC\tokens.dat" ( if exist "%ProgramData%\Microsoft\Windows\ClipSVC\tokens.dat" (
call :_color %Red% "[Failed]" call :dk_color %Red% "[Failed]"
) else ( ) else (
echo [Successful] echo [Successful]
) )
@@ -487,7 +542,7 @@ echo:
echo Deleting a Volatile ^& Protected Registry Key... echo Deleting a Volatile ^& Protected Registry Key...
echo [%RegKey%] echo [%RegKey%]
reg query "%RegKey%" %nul% && ( reg query "%RegKey%" %nul% && (
call :_color %Red% "[Failed]" call :dk_color %Red% "[Failed]"
echo Restart the system, that will delete this registry key automatically. echo Restart the system, that will delete this registry key automatically.
) || ( ) || (
echo [Successful] echo [Successful]
@@ -500,7 +555,7 @@ echo Deleting a IdentityCRL Registry Key...
echo [%_ident%] echo [%_ident%]
reg delete "%_ident%" /f %nul% reg delete "%_ident%" /f %nul%
reg query "%_ident%" %nul% && ( reg query "%_ident%" %nul% && (
call :_color %Red% "[Failed]" call :dk_color %Red% "[Failed]"
) || ( ) || (
echo [Successful] echo [Successful]
) )
@@ -515,7 +570,7 @@ echo Deleting Folder %ProgramData%\Microsoft\Windows\ClipSVC\
rmdir /s /q "C:\ProgramData\Microsoft\Windows\ClipSvc" %nul% rmdir /s /q "C:\ProgramData\Microsoft\Windows\ClipSvc" %nul%
if exist "%ProgramData%\Microsoft\Windows\ClipSVC\" ( if exist "%ProgramData%\Microsoft\Windows\ClipSVC\" (
call :_color %Red% "[Failed]" call :dk_color %Red% "[Failed]"
) else ( ) else (
echo [Successful] echo [Successful]
) )
@@ -526,7 +581,7 @@ echo Rebuilding Folder %ProgramData%\Microsoft\Windows\ClipSVC\
timeout /t 3 %nul% timeout /t 3 %nul%
if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" timeout /t 5 %nul% if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" timeout /t 5 %nul%
if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" ( if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" (
call :_color %Red% "[Failed]" call :dk_color %Red% "[Failed]"
) else ( ) else (
echo [Successful] echo [Successful]
) )
@@ -546,7 +601,7 @@ for %%# in (wlidsvc LicenseManager) do (%psc% Restart-Service %%# %nul%)
echo: echo:
echo %line% echo %line%
echo: echo:
call :_color %Blue% "Clearing Office vNext License" call :dk_color %Blue% "Clearing Office vNext License"
echo: echo:
setlocal DisableDelayedExpansion setlocal DisableDelayedExpansion
@@ -608,13 +663,13 @@ if not defined regfound echo Not Found - Office vNext Registry Keys
echo: echo:
echo %line% echo %line%
echo: echo:
call :_color %Blue% "Rebuilding SPP Licensing Tokens" call :dk_color %Blue% "Rebuilding SPP Licensing Tokens"
echo: echo:
call :scandat check call :scandat check
if not defined token ( if not defined token (
call :_color %Red% "tokens.dat file not found." call :dk_color %Red% "tokens.dat file not found."
) else ( ) else (
echo tokens.dat file: [%token%] echo tokens.dat file: [%token%]
) )
@@ -623,7 +678,7 @@ echo:
set wpainfo= set wpainfo=
for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1]);" %nul6%') do (set wpainfo=%%a) for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1]);" %nul6%') do (set wpainfo=%%a)
echo "%wpainfo%" | find /i "Error Found" %nul% && ( echo "%wpainfo%" | find /i "Error Found" %nul% && (
call :_color %Red% "WPA Registry Error: %wpainfo%" call :dk_color %Red% "WPA Registry Error: %wpainfo%"
) || ( ) || (
echo WPA Registry Count: %wpainfo% echo WPA Registry Count: %wpainfo%
) )
@@ -662,7 +717,7 @@ set "d=!d! Set-Acl -Path '%%A' -AclObject $acl"
call :checkperms call :checkperms
if defined permerror ( if defined permerror (
call :_color %Red% "[Failed To Fix]" call :dk_color %Red% "[Failed To Fix]"
) else ( ) else (
echo [Successfully Fixed] echo [Successfully Fixed]
) )
@@ -681,7 +736,7 @@ call :scandat check
if defined token ( if defined token (
echo: echo:
call :_color %Red% "Failed to delete .dat files." call :dk_color %Red% "Failed to delete .dat files."
echo: echo:
) )
@@ -692,14 +747,14 @@ if %errorlevel% NEQ 0 cscript //nologo %windir%\system32\slmgr.vbs /rilc %nul%
if %errorlevel% EQU 0 ( if %errorlevel% EQU 0 (
echo [Successful] echo [Successful]
) else ( ) else (
call :_color %Red% "[Failed]" call :dk_color %Red% "[Failed]"
) )
call :scandat check call :scandat check
echo: echo:
if not defined token ( if not defined token (
call :_color %Red% "Failed to rebuilt tokens.dat file." call :dk_color %Red% "Failed to rebuilt tokens.dat file."
) else ( ) else (
echo tokens.dat file was rebuilt successfully. echo tokens.dat file was rebuilt successfully.
) )
@@ -711,7 +766,7 @@ echo tokens.dat file was rebuilt successfully.
echo: echo:
echo %line% echo %line%
echo: echo:
call :_color %Blue% "Rebuilding OSPP Licensing Tokens" call :dk_color %Blue% "Rebuilding OSPP Licensing Tokens"
echo: echo:
sc qc osppsvc %nul% || ( sc qc osppsvc %nul% || (
@@ -723,7 +778,7 @@ goto :repairoffice
call :scandatospp check call :scandatospp check
if not defined token ( if not defined token (
call :_color %Red% "tokens.dat file not found." call :dk_color %Red% "tokens.dat file not found."
) else ( ) else (
echo tokens.dat file: [%token%] echo tokens.dat file: [%token%]
) )
@@ -738,7 +793,7 @@ call :scandatospp check
if defined token ( if defined token (
echo: echo:
call :_color %Red% "Failed to delete .dat files." call :dk_color %Red% "Failed to delete .dat files."
echo: echo:
) )
@@ -756,7 +811,7 @@ call :scandatospp check
echo: echo:
if not defined token ( if not defined token (
call :_color %Red% "Failed to rebuilt tokens.dat file." call :dk_color %Red% "Failed to rebuilt tokens.dat file."
) else ( ) else (
echo tokens.dat file was rebuilt successfully. echo tokens.dat file was rebuilt successfully.
) )
@@ -768,7 +823,7 @@ echo tokens.dat file was rebuilt successfully.
echo: echo:
echo %line% echo %line%
echo: echo:
call :_color %Blue% "Repairing Office Licenses" call :dk_color %Blue% "Repairing Office Licenses"
echo: echo:
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE') do set arch=%%b for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE') do set arch=%%b
@@ -857,8 +912,8 @@ goto :repairend
echo: echo:
) else ( ) else (
echo: echo:
call :_color %_Yellow% "A Window will popup, in that Window you need to select [Quick] Repair Option..." call :dk_color %_Yellow% "A Window will popup, in that Window you need to select [Quick] Repair Option..."
call :_color %_Yellow% "Press any key to continue..." call :dk_color %_Yellow% "Press any key to continue..."
echo: echo:
pause %nul1% pause %nul1%
) )
@@ -902,7 +957,7 @@ echo:
echo %line% echo %line%
echo: echo:
echo: echo:
call :_color %Green% "Finished" call :dk_color %Green% "Finished"
goto :at_back goto :at_back
::======================================================================================================================================== ::========================================================================================================================================
@@ -910,7 +965,7 @@ goto :at_back
:fixwmi :fixwmi
cls cls
mode 98, 34 if not defined terminal mode 98, 34
title Fix WMI title Fix WMI
:: https://techcommunity.microsoft.com/t5/ask-the-performance-team/wmi-repository-corruption-or-not/ba-p/375484 :: https://techcommunity.microsoft.com/t5/ask-the-performance-team/wmi-repository-corruption-or-not/ba-p/375484
@@ -945,7 +1000,7 @@ echo No need to apply this option. Aborting...
goto :at_back goto :at_back
) )
call :_color %Red% "[Not Responding]" call :dk_color %Red% "[Not Responding]"
set _corrupt= set _corrupt=
sc start Winmgmt %nul% sc start Winmgmt %nul%
@@ -965,7 +1020,7 @@ sc config Winmgmt start= disabled %nul%
if %errorlevel% EQU 0 ( if %errorlevel% EQU 0 (
echo [Successful] echo [Successful]
) else ( ) else (
call :_color %Red% "[Failed] Aborting..." call :dk_color %Red% "[Failed] Aborting..."
sc config Winmgmt start= auto %nul% sc config Winmgmt start= auto %nul%
goto :at_back goto :at_back
) )
@@ -978,9 +1033,9 @@ echo Stopping Winmgmt service
sc query Winmgmt | find /i "STOPPED" %nul% && ( sc query Winmgmt | find /i "STOPPED" %nul% && (
echo [Successful] echo [Successful]
) || ( ) || (
call :_color %Red% "[Failed]" call :dk_color %Red% "[Failed]"
echo: echo:
call :_color %Blue% "Its recommended to select [Restart] option and then apply Fix WMI option again." call :dk_color %Blue% "Its recommended to select [Restart] option and then apply Fix WMI option again."
echo %line% echo %line%
echo: echo:
choice /C:21 /N /M "> [1] Restart [2] Revert Back Changes :" choice /C:21 /N /M "> [1] Restart [2] Revert Back Changes :"
@@ -995,7 +1050,7 @@ echo:
echo Deleting WMI repository echo Deleting WMI repository
rmdir /s /q "%windir%\System32\wbem\repository\" %nul% rmdir /s /q "%windir%\System32\wbem\repository\" %nul%
if exist "%windir%\System32\wbem\repository\" ( if exist "%windir%\System32\wbem\repository\" (
call :_color %Red% "[Failed]" call :dk_color %Red% "[Failed]"
) else ( ) else (
echo [Successful] echo [Successful]
) )
@@ -1006,14 +1061,14 @@ sc config Winmgmt start= auto %nul%
if %errorlevel% EQU 0 ( if %errorlevel% EQU 0 (
echo [Successful] echo [Successful]
) else ( ) else (
call :_color %Red% "[Failed]" call :dk_color %Red% "[Failed]"
) )
call :checkwmi call :checkwmi
if not defined error ( if not defined error (
echo: echo:
echo Checking WMI echo Checking WMI
call :_color %Green% "[Working]" call :dk_color %Green% "[Working]"
goto :at_back goto :at_back
) )
@@ -1025,11 +1080,11 @@ echo:
echo Checking WMI echo Checking WMI
call :checkwmi call :checkwmi
if defined error ( if defined error (
call :_color %Red% "[Not Responding]" call :dk_color %Red% "[Not Responding]"
echo: echo:
echo Run [Dism RestoreHealth] and [SFC Scannow] options and make sure there are no errors. echo Run [Dism RestoreHealth] and [SFC Scannow] options and make sure there are no errors.
) else ( ) else (
call :_color %Green% "[Working]" call :dk_color %Green% "[Working]"
) )
goto :at_back goto :at_back
@@ -1077,21 +1132,12 @@ exit /b
echo: echo:
echo %line% echo %line%
echo: echo:
call :_color %_Yellow% "Press any key to go back..." call :dk_color %_Yellow% "Press any key to go back..."
pause %nul1% pause %nul1%
goto :at_menu goto :at_menu
::======================================================================================================================================== ::========================================================================================================================================
:at_done
echo:
echo Press any key to %_exitmsg%...
pause %nul1%
exit /b
::========================================================================================================================================
:compresslog :compresslog
:: https://stackoverflow.com/a/46268232 :: https://stackoverflow.com/a/46268232
@@ -1118,7 +1164,7 @@ echo/.set UniqueFiles=ON>>%ddf%
for /f "tokens=* delims=" %%D in ('dir /a:-D/b/s "%SystemRoot%\logs\%1"') do ( for /f "tokens=* delims=" %%D in ('dir /a:-D/b/s "%SystemRoot%\logs\%1"') do (
echo/"%%~fD" /inf=no;>>%ddf% echo/"%%~fD" /inf=no;>>%ddf%
) )
makecab /F %ddf% /D DiskDirectory1="" /D CabinetNameTemplate="!desktop!\AT_Logs\%2_%_time%.cab" makecab /F %ddf% /D DiskDirectory1="" /D CabinetNameTemplate="!desktop!\%2_%_time%.cab"
del /q /f %ddf% del /q /f %ddf%
exit /b exit /b
@@ -1262,106 +1308,88 @@ $key.SetAccessControl($acl)
::======================================================================================================================================== ::========================================================================================================================================
:_color :dk_done
echo:
if defined fixes (
call :dk_color2 %Blue% "Press [1] To Open Troubleshoot Page " %Gray% " Press [0] To Ignore"
choice /C:10 /N
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#))
)
if defined terminal (
call :dk_color %_Yellow% "Press 0 key to %_exitmsg%..."
choice /c 0 /n
) else (
call :dk_color %_Yellow% "Press any key to %_exitmsg%..."
pause %nul1%
)
exit /b
::========================================================================================================================================
:dk_color
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else ( ) else (
call :batcol %~1 "%~2" if not exist %psc% (echo %~3) else (%psc% write-host -back '%1' -fore '%2' '%3')
) )
exit /b exit /b
:_color2 :dk_color2
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else ( ) else (
call :batcol %~1 "%~2" %~3 "%~4" if not exist %psc% (echo %~3%~6) else (%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6')
) )
exit /b exit /b
::======================================= ::========================================================================================================================================
:: Colored text with pure batch method :: Set variables
:: Thanks to @dbenham and @jeb
:: stackoverflow.com/a/10407642
:batcol :dk_setvar
pushd %_coltemp% set psc=powershell.exe
if not exist "'" (<nul >"'" set /p "=.") set winbuild=1
setlocal for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set "s=%~2"
set "t=%~4"
call :_batcol %1 s %3 t
del /f /q "'"
del /f /q "`.txt"
popd
exit /b
:_batcol set _NCS=1
if %winbuild% LSS 10586 set _NCS=0
setlocal EnableDelayedExpansion if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
set "s=!%~2!"
set "t=!%~4!"
for /f delims^=^ eol^= %%i in ("!s!") do (
if "!" equ "" setlocal DisableDelayedExpansion
>`.txt (echo %%i\..\')
findstr /a:%~1 /f:`.txt "."
<nul set /p "=%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%"
)
if "%~4"=="" echo(&exit /b
setlocal EnableDelayedExpansion
for /f delims^=^ eol^= %%i in ("!t!") do (
if "!" equ "" setlocal DisableDelayedExpansion
>`.txt (echo %%i\..\')
findstr /a:%~3 /f:`.txt "."
<nul set /p "=%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%%_BS%"
)
echo(
exit /b
::=======================================
:_colorprep
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a"
set "Red="41;97m"" set "Red="41;97m""
set "Gray="100;97m"" set "Gray="100;97m""
set "Black="30m""
set "Green="42;97m"" set "Green="42;97m""
set "Blue="44;97m"" set "Blue="44;97m""
set "Yellow="43;97m""
set "Magenta="45;97m""
set "_Red="40;91m"" set "_Red="40;91m""
set "_Green="40;92m""
set "_Blue="40;94m""
set "_White="40;37m"" set "_White="40;37m""
set "_Green="40;92m""
set "_Yellow="40;93m"" set "_Yellow="40;93m""
) else (
exit /b set "Red="Red" "white""
set "Gray="Darkgray" "white""
set "Green="DarkGreen" "white""
set "Blue="Blue" "white""
set "_Red="Black" "Red""
set "_White="Black" "Gray""
set "_Green="Black" "Green""
set "_Yellow="Black" "Yellow""
) )
for /f %%A in ('"prompt $H&for %%B in (1) do rem"') do set "_BS=%%A %%A" set "nceline=echo: &echo ==== ERROR ==== &echo:"
set "_coltemp=%SystemRoot%\Temp" set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:"
if %~z0 GEQ 200000 (
set "Red="CF"" set "_exitmsg=Go back"
set "Gray="8F"" set "_fixmsg=Go back to Main Menu, select Troubleshoot and run Fix Licensing option."
set "Black="00"" ) else (
set "Green="2F"" set "_exitmsg=Exit"
set "Blue="1F"" set "_fixmsg=In MAS folder, run Troubleshoot script and select Fix Licensing option."
set "Yellow="6F"" )
set "Magenta="5F""
set "_Red="0C""
set "_Green="0A""
set "_Blue="09""
set "_White="07""
set "_Yellow="0E""
exit /b exit /b
::======================================================================================================================================== ::========================================================================================================================================

View File

@@ -5,7 +5,7 @@
<p align="center">A Windows and Office activator using HWID / Ohook / KMS38 / Online KMS activation methods, with a focus on open-source code and fewer antivirus detections.</p> <p align="center">A Windows and Office activator using HWID / Ohook / KMS38 / Online KMS activation methods, with a focus on open-source code and fewer antivirus detections.</p>
<p align="center"> <p align="center">
<a href="https://discord.gg/tVFN4N84PP"><img src="https://img.shields.io/discord/746721520931569757?style=social&logo=discord" alt="Chat with us without signup" title="Chat with us without signup"></a> <a href="https://discord.gg/tVFN4N84PP"><img src="https://img.shields.io/badge/Chat%20with%20us%20on%20Discord--blue?style=social&logo=discord" alt="Chat with us without signup" title="Chat with us without signup"></a>
<a href="https://www.reddit.com/r/MAS_Activator"><img src="https://img.shields.io/badge/MAS%20on%20Reddit--orange?style=social&logo=reddit" alt="MAS on Reddit" title="MAS on Reddit"></a> <a href="https://www.reddit.com/r/MAS_Activator"><img src="https://img.shields.io/badge/MAS%20on%20Reddit--orange?style=social&logo=reddit" alt="MAS on Reddit" title="MAS on Reddit"></a>
<a href="https://twitter.com/massgravel"><img src="https://img.shields.io/twitter/follow/massgravel" alt="Follow us on X" title="Follow us on X"></a> <a href="https://twitter.com/massgravel"><img src="https://img.shields.io/twitter/follow/massgravel" alt="Follow us on X" title="Follow us on X"></a>
</p> </p>
@@ -17,20 +17,31 @@
### Method 1 - PowerShell (Recommended) ### Method 1 - PowerShell (Recommended)
- Right-click on the Windows start menu and select PowerShell or Terminal (Not CMD). - Right-click on the Windows start menu and select PowerShell or Terminal (Not CMD).
- Copy-paste the below code and press enter - Copy and paste the code below and press enter
``` ```
irm https://massgrave.dev/get | iex irm https://get.activated.win | iex
``` ```
or (deprecated, will be retired on Aug 31 2024, use above instead)
```
irm https://massgrave.dev/get | iex
```
- You will see the activation options. Follow the on-screen instructions. - You will see the activation options. Follow the on-screen instructions.
- That's all. - That's all.
---
- On older Windows builds you may need to run the below command before,
`[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12`
- The Powershell method does not work on Windows 7. Use the Method 2 - Traditional instead.
- The URL get.activated.win may be blocked by some DNS services because it is a new domain.
### Method 2 - Traditional ### Method 2 - Traditional
- Download the file from [GitHub](https://github.com/massgravel/Microsoft-Activation-Scripts/archive/refs/heads/master.zip) or [Bitbucket](https://bitbucket.org/WindowsAddict/microsoft-activation-scripts/get/master.zip) - Download the file under the code button from [GitHub](https://github.com/massgravel/Microsoft-Activation-Scripts) or [Bitbucket](https://bitbucket.org/WindowsAddict/microsoft-activation-scripts)
- Right-click on the downloaded zip file and extract - Right-click on the downloaded zip file and extract
- In the extracted folder, find the folder named `All-In-One-Version` - In the extracted folder, find the folder named `All-In-One-Version`
- Run the file named `MAS_AIO.cmd` - Run the file named `MAS_AIO-CRC32_XXXXXXXX.cmd`
- You will see the activation options. Follow the on-screen instructions. - You will see the activation options, follow the on-screen instructions.
- That's all. - That's all.
To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches) To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches)