├── MAS └── Separate-Files-Version │ ├── _ReadMe.html │ ├── Activators │ └── _ReadMe.txt │ ├── Extract_OEM_Folder.cmd │ ├── Check_Activation_Status.cmd │ └── Change_Windows_Edition.cmd ├── .gitattributes ├── README.md └── LICENSE /MAS/Separate-Files-Version/_ReadMe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # MAS export-ignore 2 | # LICENSE export-ignore 3 | # README.md export-ignore 4 | # .gitattributes export-ignore 5 | -------------------------------------------------------------------------------- /MAS/Separate-Files-Version/Activators/_ReadMe.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------------- 2 | Activation Type Supported Product Activation Period 3 | -------------------------------------------------------------------------------------- 4 | 5 | HWID - Windows 10-11 - Permanent 6 | Ohook - Office - Permanent 7 | TSforge - Windows / ESU / Office - Permanent 8 | Online KMS - Windows / Office - 180 Days. Lifetime With Renewal Task 9 | 10 | -------------------------------------------------------------------------------------- 11 | 12 | Check the below link for more details: 13 | https://massgrave.dev/chart -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

MAS Logo

2 | 3 |

Microsoft Activation Scripts (MAS)

4 | 5 |

Open-source Windows and Office activator featuring HWID, Ohook, TSforge, and Online KMS activation methods, along with advanced troubleshooting.

6 | 7 |
8 | 9 | ## How to Activate Windows / Office / Extended Updates (ESU)? 10 | 11 | ### Method 1 - PowerShell ❤️ 12 | 13 | 1. **Open PowerShell** 14 | Click the **Start Menu**, type `PowerShell`, then open it. 15 | 16 | 2. **Copy and paste the code below, then press enter.** 17 | - For **Windows 8, 10, 11**: 📌 18 | ``` 19 | irm https://get.activated.win | iex 20 | ``` 21 | If the above is blocked (by ISP/DNS), try this (needs updated Windows 10 or 11): 22 | ``` 23 | iex (curl.exe -s --doh-url https://1.1.1.1/dns-query https://get.activated.win | Out-String) 24 | ``` 25 | - For **Windows 7** and later: 26 | ``` 27 | iex ((New-Object Net.WebClient).DownloadString('https://get.activated.win')) 28 | ``` 29 | - **Script not launching❓Use the below-listed Method 2.** 30 | 31 | 3. The activation menu will appear. **Choose the green-highlighted options** to activate Windows or Office. 32 | 33 | 4. **Done!** 34 | 35 | --- 36 | 37 | ### Method 2 - Traditional (Windows Vista and later) 38 | 39 | 1. Download the script: [**MAS_AIO.cmd**](https://dev.azure.com/massgrave/Microsoft-Activation-Scripts/_apis/git/repositories/Microsoft-Activation-Scripts/items?path=/MAS/All-In-One-Version-KL/MAS_AIO.cmd&download=true) or the [full ZIP](https://dev.azure.com/massgrave/Microsoft-Activation-Scripts/_apis/git/repositories/Microsoft-Activation-Scripts/items?$format=zip). 40 | 2. Run the file named `MAS_AIO.cmd`. 41 | 3. You will see the activation options. Follow the on-screen instructions. 42 | 4. That's all. 43 | 44 | --- 45 | 46 | > [!TIP] 47 | > - Some ISPs/DNS block access to our domains. You can bypass this by enabling [DNS-over-HTTPS (DoH)](https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/encrypted-dns-browsers/) in your browser. 48 | > - **Having trouble**❓Visit our [troubleshooting page](https://massgrave.dev/troubleshoot) or raise an issue on [GitHub](https://github.com/massgravel/Microsoft-Activation-Scripts/issues). 49 | 50 | --- 51 | 52 | - To activate additional products such as **Office for macOS, Visual Studio, RDS CALs, and Windows XP**, check [here](https://massgrave.dev/unsupported_products_activation). 53 | - To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches). 54 | 55 | --- 56 | 57 | > [!NOTE] 58 | > 59 | > - The IRM command in PowerShell downloads a script from a specified URL, and the IEX command executes it. 60 | > - Always double-check the URL before executing the command and verify the source if manually downloading files. 61 | > - Be cautious, as some spread malware disguised as MAS by using different URLs in the IRM command. 62 | 63 | --- 64 | 65 | ``` 66 | Latest Version: 3.9 67 | Release date: 19-Nov-2025 68 | ``` 69 | 70 | ### [Troubleshooting / Help](https://massgrave.dev/troubleshoot) 71 | ### [Download Original Windows & Office](https://massgrave.dev/genuine-installation-media) 72 | ### Homepage - [https://massgrave.dev/](https://massgrave.dev/) 73 | 74 |
75 | 76 | [![1.1]][1] 77 | [![1.2]][2] 78 | [![1.3]][3] 79 | 80 |
81 | 82 |
83 | 84 | [![1.4]][4] 85 | [![1.5]][5] 86 | [![1.6]][6] 87 | [![1.7]][7] 88 | 89 |
90 | 91 | [1.1]: https://massgrave.dev/img/logo_github.png (GitHub) 92 | [1.2]: https://massgrave.dev/img/logo_azuredevops.png (AzureDevOps) 93 | [1.3]: https://massgrave.dev/img/logo_gitea.png (Self-hosted Git) 94 | 95 | [1.4]: https://massgrave.dev/img/logo_discord.png (Chat with us without signup) 96 | [1.5]: https://massgrave.dev/img/logo_reddit.png (Reddit) 97 | [1.6]: https://massgrave.dev/img/logo_bluesky.png (Bluesky) 98 | [1.7]: https://massgrave.dev/img/logo_x.png (Twitter) 99 | 100 | [1]: https://github.com/massgravel/Microsoft-Activation-Scripts 101 | [2]: https://dev.azure.com/massgrave/_git/Microsoft-Activation-Scripts 102 | [3]: https://git.activated.win/Microsoft-Activation-Scripts 103 | [4]: https://discord.gg/j2yFsV5ZVC 104 | [5]: https://www.reddit.com/r/MAS_Activator 105 | [6]: https://bsky.app/profile/massgrave.dev 106 | [7]: https://twitter.com/massgravel 107 | 108 | --- 109 | 110 |

Made with Love ❤️

111 | 112 | -------------------------------------------------------------------------------- /MAS/Separate-Files-Version/Extract_OEM_Folder.cmd: -------------------------------------------------------------------------------- 1 | @set masver=3.9 2 | @echo off 3 | 4 | 5 | 6 | ::============================================================================ 7 | :: 8 | :: Homepage: m{}assgrave{dot}dev 9 | :: 10 | ::============================================================================ 11 | 12 | 13 | 14 | ::======================================================================================================================================== 15 | 16 | :: Set environment variables, it helps if they are misconfigured in the system 17 | 18 | setlocal EnableExtensions 19 | setlocal DisableDelayedExpansion 20 | 21 | set "PathExt=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC" 22 | 23 | set "SysPath=%SystemRoot%\System32" 24 | set "Path=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" 25 | if exist "%SystemRoot%\Sysnative\reg.exe" ( 26 | set "SysPath=%SystemRoot%\Sysnative" 27 | set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%" 28 | ) 29 | 30 | set "ComSpec=%SysPath%\cmd.exe" 31 | set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" 32 | 33 | set re1= 34 | set re2= 35 | set "_cmdf=%~f0" 36 | for %%# in (%*) do ( 37 | if /i "%%#"=="re1" set re1=1 38 | if /i "%%#"=="re2" set re2=1 39 | if /i "%%#"=="-qedit" (set re1=1&set re2=1) 40 | ) 41 | 42 | :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows 43 | :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows 44 | 45 | if exist %SystemRoot%\Sysnative\cmd.exe if not defined re1 ( 46 | setlocal EnableDelayedExpansion 47 | start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* re1" 48 | exit /b 49 | ) 50 | 51 | :: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows 52 | 53 | if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined re2 ( 54 | setlocal EnableDelayedExpansion 55 | start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* re2" 56 | exit /b 57 | ) 58 | 59 | ::======================================================================================================================================== 60 | 61 | set "blank=" 62 | set "mas=ht%blank%tps%blank%://m%blank%ass%blank%grave.dev/" 63 | set "github=ht%blank%tps%blank%://github.com/m%blank%assgra%blank%vel/Micro%blank%soft-Acti%blank%vation-Scripts" 64 | set "selfgit=ht%blank%tps%blank%://git.acti%blank%vated.win/Micr%blank%osoft-Act%blank%ivation-Scripts" 65 | 66 | :: Check if Null service is working, it's important for the batch script 67 | 68 | sc query Null | find /i "RUNNING" 69 | if %errorlevel% NEQ 0 ( 70 | echo: 71 | echo Null service is not running, script may crash... 72 | echo: 73 | echo: 74 | echo Check this webpage for help - %mas%fix_service 75 | echo: 76 | echo: 77 | ping 127.0.0.1 -n 20 78 | ) 79 | cls 80 | 81 | :: Check LF line ending 82 | 83 | pushd "%~dp0" 84 | >nul findstr /v "$" "%~nx0" && ( 85 | echo: 86 | echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. 87 | echo: 88 | echo: 89 | echo Check this webpage for help - %mas%troubleshoot 90 | echo: 91 | echo: 92 | ping 127.0.0.1 -n 20 >nul 93 | popd 94 | exit /b 95 | ) 96 | popd 97 | 98 | ::======================================================================================================================================== 99 | 100 | cls 101 | color 07 102 | title Extract $OEM$ Folder %masver% 103 | 104 | set _args= 105 | set _elev= 106 | set _unattended=0 107 | 108 | set _args=%* 109 | if defined _args set _args=%_args:"=% 110 | if defined _args set _args=%_args:re1=% 111 | if defined _args set _args=%_args:re2=% 112 | if defined _args ( 113 | for %%A in (%_args%) do ( 114 | if /i "%%A"=="-el" set _elev=1 115 | ) 116 | ) 117 | 118 | set "nul1=1>nul" 119 | set "nul2=2>nul" 120 | set "nul6=2^>nul" 121 | set "nul=>nul 2>&1" 122 | 123 | call :dk_setvar 124 | 125 | ::======================================================================================================================================== 126 | 127 | if %winbuild% EQU 1 ( 128 | %eline% 129 | echo Failed to detect Windows build number. 130 | echo: 131 | setlocal EnableDelayedExpansion 132 | set fixes=%fixes% %mas%troubleshoot 133 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" 134 | goto done2 135 | ) 136 | 137 | if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( 138 | sc query gcs | find /i "RUNNING" %nul% && ( 139 | %eline% 140 | echo Windows Sandbox detected. 141 | echo The script cannot run due to missing licensing components. Aborting... 142 | echo: 143 | goto done2 144 | ) 145 | ) 146 | 147 | if %winbuild% LSS 6001 ( 148 | %nceline% 149 | echo Unsupported OS version detected [%winbuild%]. 150 | echo MAS only supports Windows Vista/7/8/8.1/10/11 and their Server equivalents. 151 | if %winbuild% EQU 6000 ( 152 | echo: 153 | echo Windows Vista RTM is not supported because Powershell cannot be installed. 154 | echo Upgrade to Windows Vista SP1 or SP2. 155 | ) 156 | goto done2 157 | ) 158 | 159 | if %winbuild% LSS 7600 if not exist "%SysPath%\WindowsPowerShell\v1.0\Modules" ( 160 | %nceline% 161 | if not exist %ps% ( 162 | echo PowerShell is not installed in your system. 163 | ) 164 | echo Install PowerShell 2.0 using the following URL. 165 | echo: 166 | echo https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 167 | if %_unattended%==0 start https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 168 | goto done2 169 | ) 170 | 171 | ::======================================================================================================================================== 172 | 173 | :: Fix special character limitations in path name 174 | 175 | set "_work=%~dp0" 176 | if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%" 177 | 178 | set "_batf=%~f0" 179 | set "_batp=%_batf:'=''%" 180 | 181 | set _PSarg="""%~f0""" -el %_args% 182 | set _PSarg=%_PSarg:'=''% 183 | 184 | set "_ttemp=%userprofile%\AppData\Local\Temp" 185 | 186 | setlocal EnableDelayedExpansion 187 | 188 | ::======================================================================================================================================== 189 | 190 | echo "!_batf!" | find /i "!_ttemp!" %nul1% && ( 191 | if /i not "!_work!"=="!_ttemp!" ( 192 | %eline% 193 | echo The script was launched from the temp folder. 194 | echo You are most likely running the script directly from the archive file. 195 | echo: 196 | echo Extract the archive file and launch the script from the extracted folder. 197 | goto done2 198 | ) 199 | ) 200 | 201 | ::======================================================================================================================================== 202 | 203 | :: Elevate script as admin and pass arguments and preventing loop 204 | 205 | %nul1% fltmc || ( 206 | if not defined _elev %psc% "start cmd.exe -arg '/c \"!_PSarg!\"' -verb runas" && exit /b 207 | %eline% 208 | echo This script needs admin rights. 209 | echo Right click on this script and select 'Run as administrator'. 210 | goto done2 211 | ) 212 | 213 | ::======================================================================================================================================== 214 | 215 | :: Check PowerShell 216 | 217 | ::pstst $ExecutionContext.SessionState.LanguageMode :pstst 218 | 219 | for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[System.IO.File]::ReadAllText('!_batp!') -split ':pstst';. ([scriptblock]::Create($f[1]))}" %nul6%') do (set tstresult=%%a) 220 | 221 | if /i not "%tstresult%"=="FullLanguage" ( 222 | %eline% 223 | for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a) 224 | echo Test 1 - %tstresult% 225 | echo Test 2 - !tstresult2! 226 | echo: 227 | 228 | REM check LanguageMode 229 | 230 | echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( 231 | echo FullLanguage mode not found in PowerShell. Aborting... 232 | echo If you have applied restrictions on Powershell then undo those changes. 233 | echo: 234 | set fixes=%fixes% %mas%fix_powershell 235 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell" 236 | goto done2 237 | ) 238 | 239 | REM check Powershell core version 240 | 241 | cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( 242 | echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... 243 | echo: 244 | set fixes=%fixes% %mas%in-place_repair_upgrade 245 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" 246 | goto done2 247 | ) 248 | 249 | REM check for Mal-ware that may cause issues with Powershell 250 | 251 | for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" ( 252 | echo "%%f" 253 | echo Mal%blank%ware found, PowerShell is not working properly. 254 | echo: 255 | set fixes=%fixes% %mas%remove_mal%w%ware 256 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" 257 | goto done2 258 | ) 259 | 260 | REM check if .NET is working properly 261 | 262 | if /i "!tstresult2!"=="FullLanguage" ( 263 | cmd /c "%psc% ""try {[System.AppDomain]::CurrentDomain.GetAssemblies(); [System.Math]::Sqrt(144)} catch {Exit 3}""" %nul% 264 | if !errorlevel!==3 ( 265 | echo Windows Powershell failed to load .NET command. Aborting... 266 | echo: 267 | set fixes=%fixes% %mas%in-place_repair_upgrade 268 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" 269 | goto done2 270 | ) 271 | ) 272 | 273 | REM check antivirus and other errors 274 | 275 | echo PowerShell is not working properly. Aborting... 276 | 277 | if /i "!tstresult2!"=="FullLanguage" ( 278 | echo: 279 | echo Your antivirus software might be blocking the script. 280 | echo: 281 | sc query sense | find /i "RUNNING" %nul% && ( 282 | echo Installed Antivirus - Microsoft Defender for Endpoint 283 | ) 284 | cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))}""" 285 | ) 286 | 287 | echo: 288 | set fixes=%fixes% %mas%troubleshoot 289 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" 290 | goto done2 291 | ) 292 | 293 | ::======================================================================================================================================== 294 | 295 | :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app 296 | 297 | if %winbuild% GEQ 17763 ( 298 | set terminal=1 299 | ) else ( 300 | set terminal= 301 | ) 302 | 303 | :: Check if script is running in Terminal app 304 | 305 | if defined terminal ( 306 | set lines=0 307 | for /f "skip=3 tokens=* delims=" %%A in ('mode con') do if "!lines!"=="0" ( 308 | for %%B in (%%A) do set lines=%%B 309 | ) 310 | if !lines! GEQ 100 set terminal= 311 | ) 312 | 313 | if %_unattended%==1 goto :skipQE 314 | for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) 315 | 316 | :: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app 317 | :: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes 318 | :: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error 319 | 320 | set resetQE=1 321 | reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0 322 | reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1% 323 | 324 | if defined terminal ( 325 | start conhost.exe "!_batf!" %_args% -qedit 326 | start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1% 327 | exit /b 328 | ) else if %resetQE% EQU 1 ( 329 | start cmd.exe /c ""!_batf!" %_args% -qedit" 330 | start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1% 331 | exit /b 332 | ) 333 | 334 | :skipQE 335 | 336 | ::======================================================================================================================================== 337 | 338 | :: Check for updates 339 | 340 | set -= 341 | set old= 342 | set pingp= 343 | set upver=%masver:.=% 344 | 345 | for %%A in ( 346 | activ%-%ated.win 347 | mass%-%grave.dev 348 | ) do if not defined pingp ( 349 | for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do ( 350 | if not "%%B"=="" (set old=1& set pingp=1) 351 | for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do ( 352 | if not "%%C"=="" set old= 353 | ) 354 | ) 355 | ) 356 | 357 | if defined old ( 358 | echo ________________________________________________ 359 | %eline% 360 | echo Your version of MAS [%masver%] is outdated. 361 | echo ________________________________________________ 362 | echo: 363 | if not %_unattended%==1 ( 364 | echo [1] Get Latest MAS 365 | echo [0] Continue Anyway 366 | echo: 367 | call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" 368 | choice /C:10 /N 369 | if !errorlevel!==2 rem 370 | if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b) 371 | ) 372 | ) 373 | 374 | ::======================================================================================================================================== 375 | 376 | setlocal DisableDelayedExpansion 377 | 378 | :: Check desktop location 379 | 380 | set desktop= 381 | for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') do call set "desktop=%%b" 382 | if not defined desktop for /f "delims=" %%a in ('%psc% "& {write-host $([Environment]::GetFolderPath('Desktop'))}"') do call set "desktop=%%a" 383 | 384 | set "_pdesk=%desktop:'=''%" 385 | set "_dir=%desktop%\$OEM$\$$\Setup\Scripts" 386 | 387 | if exist "!desktop!\" ( 388 | %eline% 389 | echo Unable to detect Desktop location, aborting... 390 | goto done2 391 | ) 392 | 393 | setlocal EnableDelayedExpansion 394 | 395 | ::======================================================================================================================================== 396 | 397 | if not defined terminal mode 78, 30 398 | 399 | if exist "!desktop!\$OEM$\" ( 400 | echo _____________________________________________________ 401 | %eline% 402 | echo The $OEM$ folder already exists on your Desktop. 403 | echo _____________________________________________________ 404 | goto done2 405 | ) 406 | 407 | set HWID_Activation.cmd=Activators\HWID_Activation.cmd 408 | set Online_KMS_Activation.cmd=Activators\Online_KMS_Activation.cmd 409 | set Ohook_Activation_AIO.cmd=Activators\Ohook_Activation_AIO.cmd 410 | set TSforge_Activation.cmd=Activators\TSforge_Activation.cmd 411 | pushd "!_work!" 412 | 413 | set _nofile= 414 | for %%# in ( 415 | %HWID_Activation.cmd% 416 | %Online_KMS_Activation.cmd% 417 | %Ohook_Activation_AIO.cmd% 418 | %TSforge_Activation.cmd% 419 | ) do ( 420 | if not exist "%%#" set _nofile=1 421 | ) 422 | 423 | popd 424 | 425 | if defined _nofile ( 426 | echo _____________________________________________________ 427 | %eline% 428 | echo Some files are missing in the 'Activators' folder. 429 | echo _____________________________________________________ 430 | goto done2 431 | ) 432 | 433 | ::======================================================================================================================================== 434 | 435 | :Menu 436 | 437 | cls 438 | if not defined terminal mode 78, 30 439 | echo: 440 | echo: 441 | echo: 442 | echo: 443 | echo: Extract $OEM$ folder on the desktop 444 | echo: ____________________________________________________________ 445 | echo: 446 | echo: [1] HWID [Windows] 447 | echo: [2] Ohook [Office] 448 | echo: [3] TSforge [Windows / ESU / Office] 449 | echo: [4] Online KMS [Windows / Office] 450 | echo: 451 | echo: [5] HWID [Windows] ^+ Ohook [Office] 452 | echo: [6] HWID [Windows] ^+ Ohook [Office] ^+ TSforge [ESU] 453 | echo: [7] TSforge [Windows / ESU] ^+ Ohook [Office] 454 | echo: 455 | call :dk_color2 %_White% " [R] " %_Green% "ReadMe" 456 | echo: [0] Exit 457 | echo: ____________________________________________________________ 458 | echo: 459 | call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard :" 460 | choice /C:1234567R0 /N 461 | set _erl=%errorlevel% 462 | 463 | if %_erl%==9 exit /b 464 | if %_erl%==8 start %mas%oem-folder &goto :Menu 465 | if %_erl%==7 goto:tsforge_ohook 466 | if %_erl%==6 goto:hwid_ohook_tsforge 467 | if %_erl%==5 goto:hwid_ohook 468 | if %_erl%==4 goto:kms 469 | if %_erl%==3 goto:tsforge 470 | if %_erl%==2 goto:ohook 471 | if %_erl%==1 goto:hwid 472 | goto :Menu 473 | 474 | ::======================================================================================================================================== 475 | 476 | :hwid 477 | 478 | cls 479 | md "!desktop!\$OEM$\$$\Setup\Scripts" 480 | pushd "!_work!" 481 | copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul% 482 | popd 483 | call :export hwid_setup 484 | 485 | set _error= 486 | if not exist "!_dir!\HWID_Activation.cmd" set _error=1 487 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 488 | if defined _error goto errorfound 489 | 490 | set oem=HWID 491 | goto done 492 | 493 | :hwid_setup: 494 | @echo off 495 | 496 | fltmc >nul || exit /b 497 | 498 | call "%~dp0HWID_Activation.cmd" /HWID 499 | 500 | cd \ 501 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 502 | :hwid_setup: 503 | 504 | ::======================================================================================================================================== 505 | 506 | :ohook 507 | 508 | cls 509 | md "!desktop!\$OEM$\$$\Setup\Scripts" 510 | pushd "!_work!" 511 | copy /y /b %Ohook_Activation_AIO.cmd% "!_dir!\Ohook_Activation_AIO.cmd" %nul% 512 | popd 513 | call :export ohook_setup 514 | 515 | set _error= 516 | if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1 517 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 518 | if defined _error goto errorfound 519 | 520 | set oem=Ohook 521 | goto done 522 | 523 | :ohook_setup: 524 | @echo off 525 | 526 | fltmc >nul || exit /b 527 | 528 | call "%~dp0Ohook_Activation_AIO.cmd" /Ohook 529 | 530 | cd \ 531 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 532 | :ohook_setup: 533 | 534 | ::======================================================================================================================================== 535 | 536 | :tsforge 537 | 538 | cls 539 | md "!desktop!\$OEM$\$$\Setup\Scripts" 540 | pushd "!_work!" 541 | copy /y /b "%TSforge_Activation.cmd%" "!_dir!\TSforge_Activation.cmd" %nul% 542 | popd 543 | call :export tsforge_setup 544 | 545 | set _error= 546 | if not exist "!_dir!\TSforge_Activation.cmd" set _error=1 547 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 548 | if defined _error goto errorfound 549 | 550 | set oem=TSforge 551 | goto done 552 | 553 | :tsforge_setup: 554 | @echo off 555 | 556 | fltmc >nul || exit /b 557 | 558 | call "%~dp0TSforge_Activation.cmd" /Z-WindowsESUOffice 559 | 560 | cd \ 561 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 562 | :tsforge_setup: 563 | 564 | ::======================================================================================================================================== 565 | 566 | :kms 567 | 568 | cls 569 | md "!desktop!\$OEM$\$$\Setup\Scripts" 570 | pushd "!_work!" 571 | copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul% 572 | popd 573 | call :export kms_setup 574 | 575 | set _error= 576 | if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1 577 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 578 | if defined _error goto errorfound 579 | 580 | set oem=Online KMS 581 | goto done 582 | 583 | :kms_setup: 584 | @echo off 585 | 586 | fltmc >nul || exit /b 587 | 588 | call "%~dp0Online_KMS_Activation.cmd" /K-WindowsOffice 589 | 590 | cd \ 591 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 592 | :kms_setup: 593 | 594 | ::======================================================================================================================================== 595 | 596 | :hwid_ohook 597 | 598 | cls 599 | md "!desktop!\$OEM$\$$\Setup\Scripts" 600 | pushd "!_work!" 601 | copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul% 602 | copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul% 603 | popd 604 | call :export hwid_ohook_setup 605 | 606 | set _error= 607 | if not exist "!_dir!\HWID_Activation.cmd" set _error=1 608 | if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1 609 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 610 | if defined _error goto errorfound 611 | 612 | set oem=HWID [Windows] + Ohook [Office] 613 | goto done 614 | 615 | :hwid_ohook_setup: 616 | @echo off 617 | 618 | fltmc >nul || exit /b 619 | 620 | setlocal 621 | call "%~dp0HWID_Activation.cmd" /HWID 622 | endlocal 623 | 624 | setlocal 625 | call "%~dp0Ohook_Activation_AIO.cmd" /Ohook 626 | endlocal 627 | 628 | cd \ 629 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 630 | :hwid_ohook_setup: 631 | 632 | ::======================================================================================================================================== 633 | 634 | :hwid_ohook_tsforge 635 | 636 | cls 637 | md "!desktop!\$OEM$\$$\Setup\Scripts" 638 | pushd "!_work!" 639 | copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul% 640 | copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul% 641 | copy /y /b "%TSforge_Activation.cmd%" "!_dir!\TSforge_Activation.cmd" %nul% 642 | popd 643 | call :export hwid_ohook_tsforge_setup 644 | 645 | set _error= 646 | if not exist "!_dir!\HWID_Activation.cmd" set _error=1 647 | if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1 648 | if not exist "!_dir!\TSforge_Activation.cmd" set _error=1 649 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 650 | if defined _error goto errorfound 651 | 652 | set oem=HWID [Windows] + Ohook [Office] + TSforge [ESU] 653 | goto done 654 | 655 | :hwid_ohook_tsforge_setup: 656 | @echo off 657 | 658 | fltmc >nul || exit /b 659 | 660 | setlocal 661 | call "%~dp0HWID_Activation.cmd" /HWID 662 | endlocal 663 | 664 | setlocal 665 | call "%~dp0Ohook_Activation_AIO.cmd" /Ohook 666 | endlocal 667 | 668 | setlocal 669 | call "%~dp0TSforge_Activation.cmd" /Z-ESU 670 | endlocal 671 | 672 | cd \ 673 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 674 | :hwid_ohook_tsforge_setup: 675 | 676 | ::======================================================================================================================================== 677 | 678 | :tsforge_ohook 679 | 680 | cls 681 | md "!desktop!\$OEM$\$$\Setup\Scripts" 682 | pushd "!_work!" 683 | copy /y /b "%TSforge_Activation.cmd%" "!_dir!\TSforge_Activation.cmd" %nul% 684 | copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul% 685 | popd 686 | call :export tsforge_ohook_setup 687 | 688 | set _error= 689 | if not exist "!_dir!\TSforge_Activation.cmd" set _error=1 690 | if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1 691 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 692 | if defined _error goto errorfound 693 | 694 | set oem=TSforge [Windows / ESU] + Ohook [Office] 695 | goto done 696 | 697 | :tsforge_ohook_setup: 698 | @echo off 699 | 700 | fltmc >nul || exit /b 701 | 702 | setlocal 703 | call "%~dp0TSforge_Activation.cmd" /Z-Windows /Z-ESU 704 | endlocal 705 | 706 | setlocal 707 | call "%~dp0Ohook_Activation_AIO.cmd" /Ohook 708 | endlocal 709 | 710 | cd \ 711 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 712 | :tsforge_ohook_setup: 713 | 714 | ::======================================================================================================================================== 715 | 716 | :errorfound 717 | 718 | %eline% 719 | echo The script failed to create the $OEM$ folder. 720 | goto :done2 721 | 722 | :done 723 | 724 | echo ______________________________________________________________ 725 | echo: 726 | call :dk_color %Blue% "%oem%" 727 | call :dk_color %Green% "$OEM$ folder was successfully created on your Desktop." 728 | echo ______________________________________________________________ 729 | 730 | :done2 731 | 732 | echo: 733 | if defined fixes ( 734 | call :dk_color %White% "Follow ALL the ABOVE blue lines. " 735 | call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" 736 | choice /C:10 /N 737 | if !errorlevel!==2 exit /b 738 | if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) 739 | ) 740 | 741 | if defined terminal ( 742 | call :dk_color %_Yellow% "Press [0] key to %_exitmsg%..." 743 | choice /c 0 /n 744 | ) else ( 745 | call :dk_color %_Yellow% "Press any key to %_exitmsg%..." 746 | pause %nul1% 747 | ) 748 | exit /b 749 | 750 | ::======================================================================================================================================== 751 | 752 | :: Set variables 753 | 754 | :dk_setvar 755 | 756 | set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe 757 | set psc=%ps% -nop -c 758 | set winbuild=1 759 | for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" 760 | 761 | set _slexe=sppsvc.exe& set _slser=sppsvc 762 | if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc) 763 | if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc) 764 | if %_slexe%==SLsvc.exe set _vis=1 765 | 766 | set _NCS=1 767 | if %winbuild% LSS 10586 set _NCS=0 768 | if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) 769 | 770 | echo "%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%" | find /i "ARM64" %nul1% && (if %winbuild% LSS 21277 set ps32onArm=1) 771 | 772 | if %_NCS% EQU 1 ( 773 | for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" 774 | set "Red="41;97m"" 775 | set "Gray="100;97m"" 776 | set "Green="42;97m"" 777 | set "Blue="44;97m"" 778 | set "White="107;91m"" 779 | set "_Red="40;91m"" 780 | set "_White="40;37m"" 781 | set "_Green="40;92m"" 782 | set "_Yellow="40;93m"" 783 | ) else ( 784 | set "Red="Red" "white"" 785 | set "Gray="Darkgray" "white"" 786 | set "Green="DarkGreen" "white"" 787 | set "Blue="Blue" "white"" 788 | set "White="White" "Red"" 789 | set "_Red="Black" "Red"" 790 | set "_White="Black" "Gray"" 791 | set "_Green="Black" "Green"" 792 | set "_Yellow="Black" "Yellow"" 793 | ) 794 | 795 | set "nceline=echo: &echo ==== ERROR ==== &echo:" 796 | set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:" 797 | if %~z0 GEQ 200000 ( 798 | set "_exitmsg=Go back" 799 | set "_fixmsg=Go back to Main Menu, select Troubleshoot and run Fix Licensing option." 800 | ) else ( 801 | set "_exitmsg=Exit" 802 | set "_fixmsg=In MAS folder, run Troubleshoot script and select Fix Licensing option." 803 | ) 804 | exit /b 805 | 806 | ::======================================================================================================================================== 807 | 808 | :: Extract the text from batch script without character and file encoding issue 809 | 810 | :export 811 | 812 | %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split \":%~1\:.*`r`n\"; [io.file]::WriteAllText('!_pdesk!\$OEM$\$$\Setup\Scripts\SetupComplete.cmd',$f[1].Trim(),[System.Text.Encoding]::ASCII);" 813 | exit /b 814 | 815 | ::======================================================================================================================================== 816 | 817 | :dk_color 818 | 819 | if %_NCS% EQU 1 ( 820 | echo %esc%[%~1%~2%esc%[0m 821 | ) else if exist %ps% ( 822 | %psc% write-host -back '%1' -fore '%2' '%3' 823 | ) else if not exist %ps% ( 824 | echo %~3 825 | ) 826 | exit /b 827 | 828 | :dk_color2 829 | 830 | if %_NCS% EQU 1 ( 831 | echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m 832 | ) else if exist %ps% ( 833 | %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' 834 | ) else if not exist %ps% ( 835 | echo %~3 %~6 836 | ) 837 | exit /b 838 | 839 | ::======================================================================================================================================== 840 | :: Leave empty line below 841 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MAS/Separate-Files-Version/Check_Activation_Status.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | 4 | :: Check-Activation-Status 5 | :: Written by @abbodi1406 6 | :: https://gravesoft.dev/cas 7 | 8 | 9 | :: Set Environment variables, it helps if they are misconfigured in the system 10 | 11 | setlocal EnableExtensions 12 | setlocal DisableDelayedExpansion 13 | 14 | set "PathExt=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC" 15 | 16 | set "SysPath=%SystemRoot%\System32" 17 | set "Path=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" 18 | if exist "%SystemRoot%\Sysnative\reg.exe" ( 19 | set "SysPath=%SystemRoot%\Sysnative" 20 | set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%" 21 | ) 22 | 23 | set "ComSpec=%SysPath%\cmd.exe" 24 | set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" 25 | 26 | set "ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe" 27 | set "_psc=%ps% -nop -c" 28 | set "_err===== ERROR ====" 29 | set _pwsh=1 30 | if not exist %ps% set _pwsh=0 31 | cmd /c "%_psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" 1>nul || (set _pwsh=0) 32 | if %_pwsh% equ 0 ( 33 | echo %_err% 34 | cmd /c "%_psc% "$ExecutionContext.SessionState.LanguageMode"" 35 | echo Windows PowerShell is not working correctly. 36 | echo It is required for this script to work. 37 | goto :E_Exit 38 | ) 39 | set "_batf=%~f0" 40 | set "_batp=%_batf:'=''%" 41 | setlocal EnableDelayedExpansion 42 | %_psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':sppmgr\:.*';. ([scriptblock]::Create($f[1]))" 43 | 44 | :E_Exit 45 | echo. 46 | echo Press 0 key to exit. 47 | choice /c 0 /n 48 | exit /b 49 | 50 | :sppmgr: 51 | param ( 52 | [Parameter()] 53 | [switch] 54 | $All, 55 | [Parameter()] 56 | [switch] 57 | $Dlv, 58 | [Parameter()] 59 | [switch] 60 | $IID, 61 | [Parameter()] 62 | [switch] 63 | $Pass 64 | ) 65 | 66 | function CONOUT($strObj) 67 | { 68 | Out-Host -Input $strObj 69 | } 70 | 71 | function ExitScript($ExitCode = 0) 72 | { 73 | Exit $ExitCode 74 | } 75 | 76 | if (-Not $PSVersionTable) { 77 | "==== ERROR ====`r`n" 78 | "Windows PowerShell 1.0 is not supported by this script." 79 | ExitScript 1 80 | } 81 | 82 | if ($ExecutionContext.SessionState.LanguageMode.value__ -NE 0) { 83 | "==== ERROR ====`r`n" 84 | "Windows PowerShell is not running in Full Language Mode." 85 | ExitScript 1 86 | } 87 | 88 | $winbuild = 1 89 | try { 90 | $winbuild = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$env:SystemRoot\System32\kernel32.dll").FileBuildPart 91 | } catch { 92 | $winbuild = [int]([wmi]'Win32_OperatingSystem=@').BuildNumber 93 | } 94 | 95 | if ($winbuild -EQ 1) { 96 | "==== ERROR ====`r`n" 97 | "Could not detect Windows build." 98 | ExitScript 1 99 | } 100 | 101 | if ($winbuild -LT 2600) { 102 | "==== ERROR ====`r`n" 103 | "This build of Windows is not supported by this script." 104 | ExitScript 1 105 | } 106 | 107 | if ($All.IsPresent) 108 | { 109 | $isAll = {CONOUT "`r"} 110 | $noAll = {$null} 111 | } 112 | else 113 | { 114 | $isAll = {$null} 115 | $noAll = {CONOUT "`r"} 116 | } 117 | $Dlv = $Dlv.IsPresent 118 | $IID = $IID.IsPresent -Or $Dlv.IsPresent 119 | 120 | $NT6 = $winbuild -GE 6000 121 | $NT7 = $winbuild -GE 7600 122 | $NT8 = $winbuild -GE 9200 123 | $NT9 = $winbuild -GE 9600 124 | 125 | $Admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) 126 | 127 | $line2 = "============================================================" 128 | $line3 = "____________________________________________________________" 129 | 130 | function echoWindows 131 | { 132 | CONOUT "$line2" 133 | CONOUT "=== Windows Status ===" 134 | CONOUT "$line2" 135 | & $noAll 136 | } 137 | 138 | function echoOffice 139 | { 140 | if ($doMSG -EQ 0) { 141 | return 142 | } 143 | 144 | & $isAll 145 | CONOUT "$line2" 146 | CONOUT "=== Office Status ===" 147 | CONOUT "$line2" 148 | & $noAll 149 | 150 | $script:doMSG = 0 151 | } 152 | 153 | function strGetRegistry($strKey, $strName) 154 | { 155 | try { 156 | return [Microsoft.Win32.Registry]::GetValue($strKey, $strName, $null) 157 | } catch { 158 | return $null 159 | } 160 | } 161 | 162 | function CheckOhook 163 | { 164 | $ohook = 0 165 | $paths = "${env:ProgramFiles}", "${env:ProgramW6432}", "${env:ProgramFiles(x86)}" 166 | 167 | 15, 16 | foreach ` 168 | { 169 | $A = $_; $paths | foreach ` 170 | { 171 | if (Test-Path "$($_)$('\Microsoft Office\Office')$($A)$('\sppc*dll')") {$ohook = 1} 172 | } 173 | } 174 | 175 | "System", "SystemX86" | foreach ` 176 | { 177 | $A = $_; "Office 15", "Office" | foreach ` 178 | { 179 | $B = $_; $paths | foreach ` 180 | { 181 | if (Test-Path "$($_)$('\Microsoft ')$($B)$('\root\vfs\')$($A)$('\sppc*dll')") {$ohook = 1} 182 | } 183 | } 184 | } 185 | 186 | if ($ohook -EQ 0) { 187 | return 188 | } 189 | 190 | & $isAll 191 | CONOUT "$line2" 192 | CONOUT "=== Office Ohook Status ===" 193 | CONOUT "$line2" 194 | $host.UI.WriteLine('Yellow', 'Black', "`r`nOhook for permanent Office activation is installed.`r`nYou can ignore the below mentioned Office activation status.") 195 | & $noAll 196 | } 197 | 198 | #region SSSS 199 | function BoolToWStr($bVal) { 200 | ("TRUE", "FALSE")[!$bVal] 201 | } 202 | 203 | function InitializePInvoke($LaDll, $bOffice) { 204 | $LaName = [IO.Path]::GetFileNameWithoutExtension($LaDll) 205 | $SLApp = $NT7 -Or $bOffice -Or ($LaName -EQ 'sppc' -And [Diagnostics.FileVersionInfo]::GetVersionInfo("$SysPath\sppc.dll").FilePrivatePart -GE 16501) 206 | $Win32 = $null 207 | 208 | $Marshal = [System.Runtime.InteropServices.Marshal] 209 | $Module = [AppDomain]::CurrentDomain.DefineDynamicAssembly(($LaName+"_Assembly"), 'Run').DefineDynamicModule(($LaName+"_Module"), $False) 210 | $Class = $Module.DefineType(($LaName+"_Methods"), 'Public, Abstract, Sealed, BeforeFieldInit', [Object], 0) 211 | 212 | $Class.DefinePInvokeMethod('SLClose', $LaDll, 22, 1, [Int32], @([IntPtr]), 1, 3).SetImplementationFlags(128) 213 | $Class.DefinePInvokeMethod('SLOpen', $LaDll, 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) 214 | $Class.DefinePInvokeMethod('SLGenerateOfflineInstallationId', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) 215 | $Class.DefinePInvokeMethod('SLGetSLIDList', $LaDll, 22, 1, [Int32], @([IntPtr], [UInt32], [Guid].MakeByRefType(), [UInt32], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) 216 | $Class.DefinePInvokeMethod('SLGetLicensingStatusInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [Guid].MakeByRefType(), [IntPtr], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) 217 | $Class.DefinePInvokeMethod('SLGetPKeyInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) 218 | $Class.DefinePInvokeMethod('SLGetProductSkuInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) 219 | $Class.DefinePInvokeMethod('SLGetServiceInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) 220 | if ($SLApp) { 221 | $Class.DefinePInvokeMethod('SLGetApplicationInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) 222 | } 223 | if ($bOffice) { 224 | $Win32 = $Class.CreateType() 225 | return 226 | } 227 | if ($NT6) { 228 | $Class.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) 229 | $Class.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType()), 1, 3).SetImplementationFlags(128) 230 | $Class.DefinePInvokeMethod('SLIsGenuineLocal', 'slwga.dll', 22, 1, [Int32], @([Guid].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr]), 1, 3).SetImplementationFlags(128) 231 | } 232 | if ($NT7) { 233 | $Class.DefinePInvokeMethod('SLIsWindowsGenuineLocal', 'slc.dll', 'Public, Static', 'Standard', [Int32], @([UInt32].MakeByRefType()), 'Winapi', 'Unicode').SetImplementationFlags('PreserveSig') 234 | } 235 | 236 | if ($DllSubscription) { 237 | $Class.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) 238 | $Struct = $Class.DefineNestedType('SubStatus', 'NestedPublic, SequentialLayout, Sealed, BeforeFieldInit', [ValueType], 0) 239 | [void]$Struct.DefineField('dwEnabled', [UInt32], 'Public') 240 | [void]$Struct.DefineField('dwSku', [UInt32], 6) 241 | [void]$Struct.DefineField('dwState', [UInt32], 6) 242 | $SubStatus = $Struct.CreateType() 243 | } 244 | 245 | $Win32 = $Class.CreateType() 246 | } 247 | 248 | function SlGetInfoIID($SkuId) 249 | { 250 | $bData = 0 251 | 252 | if ($Win32::SLGenerateOfflineInstallationId( 253 | $hSLC, 254 | [ref][Guid]$SkuId, 255 | [ref]$bData 256 | )) 257 | { 258 | return $null 259 | } 260 | else 261 | { 262 | return $Marshal::PtrToStringUni($bData) 263 | } 264 | } 265 | 266 | function SlReturnData($hrRet, $tData, $cData, $bData) { 267 | if ($hrRet -NE 0 -Or $cData -EQ 0) 268 | { 269 | return $null 270 | } 271 | if ($tData -EQ 1) 272 | { 273 | return $Marshal::PtrToStringUni($bData) 274 | } 275 | elseif ($tData -EQ 4) 276 | { 277 | return $Marshal::ReadInt32($bData) 278 | } 279 | elseif ($tData -EQ 3 -And $cData -EQ 8) 280 | { 281 | return $Marshal::ReadInt64($bData) 282 | } 283 | else 284 | { 285 | return $null 286 | } 287 | } 288 | 289 | function SlGetInfoPKey($PkeyId, $Value) 290 | { 291 | $tData = 0 292 | $cData = 0 293 | $bData = 0 294 | 295 | $hrRet = $Win32::SLGetPKeyInformation( 296 | $hSLC, 297 | [ref][Guid]$PkeyId, 298 | $Value, 299 | [ref]$tData, 300 | [ref]$cData, 301 | [ref]$bData 302 | ) 303 | 304 | return SlReturnData $hrRet $tData $cData $bData 305 | } 306 | 307 | function SlGetInfoSku($SkuId, $Value) 308 | { 309 | $tData = 0 310 | $cData = 0 311 | $bData = 0 312 | 313 | $hrRet = $Win32::SLGetProductSkuInformation( 314 | $hSLC, 315 | [ref][Guid]$SkuId, 316 | $Value, 317 | [ref]$tData, 318 | [ref]$cData, 319 | [ref]$bData 320 | ) 321 | 322 | return SlReturnData $hrRet $tData $cData $bData 323 | } 324 | 325 | function SlGetInfoApp($AppId, $Value) 326 | { 327 | $tData = 0 328 | $cData = 0 329 | $bData = 0 330 | 331 | $hrRet = $Win32::SLGetApplicationInformation( 332 | $hSLC, 333 | [ref][Guid]$AppId, 334 | $Value, 335 | [ref]$tData, 336 | [ref]$cData, 337 | [ref]$bData 338 | ) 339 | 340 | return SlReturnData $hrRet $tData $cData $bData 341 | } 342 | 343 | function SlGetInfoService($Value) 344 | { 345 | $tData = 0 346 | $cData = 0 347 | $bData = 0 348 | 349 | $hrRet = $Win32::SLGetServiceInformation( 350 | $hSLC, 351 | $Value, 352 | [ref]$tData, 353 | [ref]$cData, 354 | [ref]$bData 355 | ) 356 | 357 | return SlReturnData $hrRet $tData $cData $bData 358 | } 359 | 360 | function SlGetInfoSvcApp($strApp, $Value) 361 | { 362 | if ($SLApp) 363 | { 364 | return SlGetInfoApp $strApp $Value 365 | } 366 | else 367 | { 368 | return SlGetInfoService $Value 369 | } 370 | } 371 | 372 | function SlGetInfoLicensing($AppId, $SkuId) 373 | { 374 | $dwStatus = 0 375 | $dwGrace = 0 376 | $hrReason = 0 377 | $qwValidity = 0 378 | 379 | $cStatus = 0 380 | $pStatus = 0 381 | 382 | $hrRet = $Win32::SLGetLicensingStatusInformation( 383 | $hSLC, 384 | [ref][Guid]$AppId, 385 | [ref][Guid]$SkuId, 386 | 0, 387 | [ref]$cStatus, 388 | [ref]$pStatus 389 | ) 390 | 391 | if ($hrRet -NE 0 -Or $cStatus -EQ 0) 392 | { 393 | return 394 | } 395 | 396 | [IntPtr]$ppStatus = [Int64]$pStatus + [Int64]40 * ($cStatus - 1) 397 | $dwStatus = $Marshal::ReadInt32($ppStatus, 16) 398 | $dwGrace = $Marshal::ReadInt32($ppStatus, 20) 399 | $hrReason = $Marshal::ReadInt32($ppStatus, 28) 400 | $qwValidity = $Marshal::ReadInt64($ppStatus, 32) 401 | 402 | if ($dwStatus -EQ 3) 403 | { 404 | $dwStatus = 5 405 | } 406 | if ($dwStatus -EQ 2) 407 | { 408 | if ($hrReason -EQ 0x4004F00D) 409 | { 410 | $dwStatus = 3 411 | } 412 | elseif ($hrReason -EQ 0x4004F065) 413 | { 414 | $dwStatus = 4 415 | } 416 | elseif ($hrReason -EQ 0x4004FC06) 417 | { 418 | $dwStatus = 6 419 | } 420 | } 421 | 422 | return 423 | } 424 | 425 | function SlGetInfoSLID($AppId) 426 | { 427 | $cReturnIds = 0 428 | $pReturnIds = 0 429 | 430 | $hrRet = $Win32::SLGetSLIDList( 431 | $hSLC, 432 | 0, 433 | [ref][Guid]$AppId, 434 | 1, 435 | [ref]$cReturnIds, 436 | [ref]$pReturnIds 437 | ) 438 | 439 | if ($hrRet -NE 0 -Or $cReturnIds -EQ 0) 440 | { 441 | return 442 | } 443 | 444 | $a1List = @() 445 | $a2List = @() 446 | $a3List = @() 447 | $a4List = @() 448 | 449 | foreach ($i in 0..($cReturnIds - 1)) 450 | { 451 | $bytes = New-Object byte[] 16 452 | $Marshal::Copy([Int64]$pReturnIds + [Int64]16 * $i, $bytes, 0, 16) 453 | $actid = ([Guid]$bytes).Guid 454 | $gPPK = SlGetInfoSku $actid "pkeyId" 455 | $gAdd = SlGetInfoSku $actid "DependsOn" 456 | if ($All.IsPresent) { 457 | if ($null -EQ $gPPK -And $null -NE $gAdd) { $a1List += @{id = $actid; pk = $null; ex = $true} } 458 | if ($null -EQ $gPPK -And $null -EQ $gAdd) { $a2List += @{id = $actid; pk = $null; ex = $false} } 459 | } 460 | if ($null -NE $gPPK -And $null -NE $gAdd) { $a3List += @{id = $actid; pk = $gPPK; ex = $true} } 461 | if ($null -NE $gPPK -And $null -EQ $gAdd) { $a4List += @{id = $actid; pk = $gPPK; ex = $false} } 462 | } 463 | 464 | return ($a1List + $a2List + $a3List + $a4List) 465 | } 466 | 467 | function DetectSubscription { 468 | try 469 | { 470 | $objSvc = New-Object PSObject 471 | $wmiSvc = [wmisearcher]"SELECT SubscriptionType, SubscriptionStatus, SubscriptionEdition, SubscriptionExpiry FROM SoftwareLicensingService" 472 | $wmiSvc.Options.Rewindable = $false 473 | $wmiSvc.Get() | select -Expand Properties -EA 0 | foreach { $objSvc | Add-Member 8 $_.Name $_.Value } 474 | $wmiSvc.Dispose() 475 | } 476 | catch 477 | { 478 | return 479 | } 480 | 481 | if ($null -EQ $objSvc.SubscriptionType -Or $objSvc.SubscriptionType -EQ 120) { 482 | return 483 | } 484 | 485 | if ($objSvc.SubscriptionType -EQ 1) { 486 | $SubMsgType = "Device based" 487 | } else { 488 | $SubMsgType = "User based" 489 | } 490 | 491 | if ($objSvc.SubscriptionStatus -EQ 120) { 492 | $SubMsgStatus = "Expired" 493 | } elseif ($objSvc.SubscriptionStatus -EQ 100) { 494 | $SubMsgStatus = "Disabled" 495 | } elseif ($objSvc.SubscriptionStatus -EQ 1) { 496 | $SubMsgStatus = "Active" 497 | } else { 498 | $SubMsgStatus = "Not active" 499 | } 500 | 501 | $SubMsgExpiry = "Unknown" 502 | if ($objSvc.SubscriptionExpiry) { 503 | if ($objSvc.SubscriptionExpiry.Contains("unspecified") -EQ $false) {$SubMsgExpiry = $objSvc.SubscriptionExpiry} 504 | } 505 | 506 | $SubMsgEdition = "Unknown" 507 | if ($objSvc.SubscriptionEdition) { 508 | if ($objSvc.SubscriptionEdition.Contains("UNKNOWN") -EQ $false) {$SubMsgEdition = $objSvc.SubscriptionEdition} 509 | } 510 | 511 | CONOUT "`nSubscription information:" 512 | CONOUT " Type : $SubMsgType" 513 | CONOUT " Status : $SubMsgStatus" 514 | CONOUT " Edition: $SubMsgEdition" 515 | CONOUT " Expiry : $SubMsgExpiry" 516 | } 517 | 518 | function DetectAdbaClient 519 | { 520 | $propADBA | foreach { set $_ (SlGetInfoSku $licID $_) } 521 | DetectActType 522 | CONOUT "`nAD Activation client information:" 523 | CONOUT " Object Name: $ADActivationObjectName" 524 | CONOUT " Domain Name: $ADActivationObjectDN" 525 | CONOUT " CSVLK Extended PID: $ADActivationCsvlkPID" 526 | CONOUT " CSVLK Activation ID: $ADActivationCsvlkSkuID" 527 | } 528 | 529 | function DetectAvmClient 530 | { 531 | $propAVMA | foreach { set $_ (SlGetInfoSku $licID $_) } 532 | CONOUT "`nAutomatic VM Activation client information:" 533 | if (-Not [String]::IsNullOrEmpty($InheritedActivationId)) { 534 | CONOUT " Guest IAID: $InheritedActivationId" 535 | } else { 536 | CONOUT " Guest IAID: Not Available" 537 | } 538 | if (-Not [String]::IsNullOrEmpty($InheritedActivationHostMachineName)) { 539 | CONOUT " Host machine name: $InheritedActivationHostMachineName" 540 | } else { 541 | CONOUT " Host machine name: Not Available" 542 | } 543 | if (-Not [String]::IsNullOrEmpty($InheritedActivationHostDigitalPid2)) { 544 | CONOUT " Host Digital PID2: $InheritedActivationHostDigitalPid2" 545 | } else { 546 | CONOUT " Host Digital PID2: Not Available" 547 | } 548 | if ($InheritedActivationActivationTime) { 549 | $IAAT = [DateTime]::FromFileTime($InheritedActivationActivationTime).ToString('yyyy-MM-dd hh:mm:ss tt') 550 | CONOUT " Activation time: $IAAT" 551 | } else { 552 | CONOUT " Activation time: Not Available" 553 | } 554 | } 555 | 556 | function DetectKmsHost 557 | { 558 | $IsKeyManagementService = SlGetInfoSvcApp $strApp 'IsKeyManagementService' 559 | if (-Not $IsKeyManagementService) { 560 | return 561 | } 562 | 563 | if ($Vista -Or $NT5) { 564 | $regk = $SLKeyPath 565 | } elseif ($strSLP -EQ $oslp) { 566 | $regk = $OPKeyPath 567 | } else { 568 | $regk = $SPKeyPath 569 | } 570 | $KMSListening = strGetRegistry $regk "KeyManagementServiceListeningPort" 571 | $KMSPublishing = strGetRegistry $regk "DisableDnsPublishing" 572 | $KMSPriority = strGetRegistry $regk "EnableKmsLowPriority" 573 | 574 | if (-Not $KMSListening) {$KMSListening = 1688} 575 | if (-Not $KMSPublishing) {$KMSPublishing = "TRUE"} else {$KMSPublishing = BoolToWStr (!$KMSPublishing)} 576 | if (-Not $KMSPriority) {$KMSPriority = "FALSE"} else {$KMSPriority = BoolToWStr $KMSPriority} 577 | 578 | if ($KMSPublishing -EQ "TRUE") {$KMSPublishing = "Enabled"} else {$KMSPublishing = "Disabled"} 579 | if ($KMSPriority -EQ "TRUE") {$KMSPriority = "Low"} else {$KMSPriority = "Normal"} 580 | 581 | if ($SLApp) 582 | { 583 | $propKMSServer | foreach { set $_ (SlGetInfoApp $strApp $_) } 584 | } 585 | else 586 | { 587 | $propKMSServer | foreach { set $_ (SlGetInfoService $_) } 588 | } 589 | 590 | $KMSRequests = $KeyManagementServiceTotalRequests 591 | $NoRequests = ($null -EQ $KMSRequests) -Or ($KMSRequests -EQ -1) -Or ($KMSRequests -EQ 4294967295) 592 | 593 | CONOUT "`nKey Management Service host information:" 594 | CONOUT " Current count: $KeyManagementServiceCurrentCount" 595 | CONOUT " Listening on Port: $KMSListening" 596 | CONOUT " DNS publishing: $KMSPublishing" 597 | CONOUT " KMS priority: $KMSPriority" 598 | if ($NoRequests) { 599 | return 600 | } 601 | CONOUT "`nKey Management Service cumulative requests received from clients:" 602 | CONOUT " Total: $KeyManagementServiceTotalRequests" 603 | CONOUT " Failed: $KeyManagementServiceFailedRequests" 604 | CONOUT " Unlicensed: $KeyManagementServiceUnlicensedRequests" 605 | CONOUT " Licensed: $KeyManagementServiceLicensedRequests" 606 | CONOUT " Initial grace period: $KeyManagementServiceOOBGraceRequests" 607 | CONOUT " Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests" 608 | CONOUT " Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests" 609 | if ($null -NE $KeyManagementServiceNotificationRequests) {CONOUT " Notification: $KeyManagementServiceNotificationRequests"} 610 | } 611 | 612 | function DetectActType 613 | { 614 | $VLType = strGetRegistry ($SPKeyPath + '\' + $strApp + '\' + $licID) "VLActivationType" 615 | if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp) "VLActivationType"} 616 | if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath) "VLActivationType"} 617 | if ($null -EQ $VLType -Or $VLType -GT 3) {$VLType = 0} 618 | if ($null -NE $VLType) {CONOUT "Configured Activation Type: $($VLActTypes[$VLType])"} 619 | } 620 | 621 | function DetectKmsClient 622 | { 623 | if ($win8) {DetectActType} 624 | CONOUT "`r" 625 | if ($LicenseStatus -NE 1) { 626 | CONOUT "Please activate the product in order to update KMS client information values." 627 | return 628 | } 629 | 630 | if ($NT7 -Or $strSLP -EQ $oslp) { 631 | $propKMSClient | foreach { set $_ (SlGetInfoSku $licID $_) } 632 | if ($strSLP -EQ $oslp) {$regk = $OPKeyPath} else {$regk = $SPKeyPath} 633 | $KMSCaching = strGetRegistry $regk "DisableKeyManagementServiceHostCaching" 634 | if (-Not $KMSCaching) {$KMSCaching = "TRUE"} else {$KMSCaching = BoolToWStr (!$KMSCaching)} 635 | } 636 | 637 | "ClientMachineID" | foreach { set $_ (SlGetInfoService $_) } 638 | 639 | if ($Vista) { 640 | $propKMSVista | foreach { set $_ (SlGetInfoService $_) } 641 | $KeyManagementServicePort = strGetRegistry $SLKeyPath "KeyManagementServicePort" 642 | $DiscoveredKeyManagementServiceName = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServiceName" 643 | $DiscoveredKeyManagementServicePort = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServicePort" 644 | } 645 | 646 | if ([String]::IsNullOrEmpty($KeyManagementServiceName)) { 647 | $KmsReg = $null 648 | } else { 649 | if (-Not $KeyManagementServicePort) {$KeyManagementServicePort = 1688} 650 | $KmsReg = "Registered KMS machine name: ${KeyManagementServiceName}:${KeyManagementServicePort}" 651 | } 652 | 653 | if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceName)) { 654 | $KmsDns = "DNS auto-discovery: KMS name not available" 655 | if ($Vista -And -Not $Admin) {$KmsDns = "DNS auto-discovery: Run the script as administrator to retrieve info"} 656 | } else { 657 | if (-Not $DiscoveredKeyManagementServicePort) {$DiscoveredKeyManagementServicePort = 1688} 658 | $KmsDns = "KMS machine name from DNS: ${DiscoveredKeyManagementServiceName}:${DiscoveredKeyManagementServicePort}" 659 | } 660 | 661 | if ($null -NE $KMSCaching) { 662 | if ($KMSCaching -EQ "TRUE") {$KMSCaching = "Enabled"} else {$KMSCaching = "Disabled"} 663 | } 664 | 665 | if ($strSLP -EQ $wslp -And $NT9) { 666 | if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceIpAddress)) { 667 | $DiscoveredKeyManagementServiceIpAddress = "not available" 668 | } 669 | } 670 | 671 | CONOUT "Key Management Service client information:" 672 | CONOUT " Client Machine ID (CMID): $ClientMachineID" 673 | if ($null -EQ $KmsReg) { 674 | CONOUT " $KmsDns" 675 | CONOUT " Registered KMS machine name: KMS name not available" 676 | } else { 677 | CONOUT " $KmsReg" 678 | } 679 | if ($null -NE $DiscoveredKeyManagementServiceIpAddress) {CONOUT " KMS machine IP address: $DiscoveredKeyManagementServiceIpAddress"} 680 | CONOUT " KMS machine extended PID: $CustomerPID" 681 | CONOUT " Activation interval: $VLActivationInterval minutes" 682 | CONOUT " Renewal interval: $VLRenewalInterval minutes" 683 | if ($null -NE $KMSCaching) {CONOUT " KMS host caching: $KMSCaching"} 684 | if (-Not [String]::IsNullOrEmpty($KeyManagementServiceLookupDomain)) {CONOUT " KMS SRV record lookup domain: $KeyManagementServiceLookupDomain"} 685 | } 686 | 687 | function GetResult($strSLP, $strApp, $entry) 688 | { 689 | $licID = $entry.id 690 | $propPrd | foreach { set $_ (SlGetInfoSku $licID $_) } 691 | . SlGetInfoLicensing $strApp $licID 692 | $LicenseStatus = $dwStatus 693 | $LicReason = $hrReason 694 | $EvaluationEndDate = $qwValidity 695 | $gprMnt = $dwGrace 696 | 697 | $pkid = $entry.pk 698 | $isPPK = $null -NE $pkid 699 | 700 | $add_on = $Name.IndexOf("add-on for", 5) 701 | if ($add_on -NE -1) { 702 | $Name = $Name.Substring(0, $add_on + 7) 703 | } 704 | 705 | $licPHN = "empty" 706 | if ($Dlv -Or $All.IsPresent) { 707 | $licPHN = SlGetInfoSku $licID "msft:sl/EUL/PHONE/PUBLIC" 708 | } 709 | 710 | if ($LicenseStatus -EQ 0 -And !$isPPK) { 711 | & $isAll 712 | CONOUT "Name: $Name" 713 | CONOUT "Description: $Description" 714 | CONOUT "Activation ID: $licID" 715 | CONOUT "License Status: Unlicensed" 716 | if ($licPHN -NE "empty") { 717 | $gPHN = [String]::IsNullOrEmpty($licPHN) -NE $true 718 | CONOUT "Phone activatable: $($gPHN.ToString())" 719 | } 720 | return 721 | } 722 | 723 | $winID = ($strApp -EQ $winApp) 724 | $winPR = ($winID -And -Not $entry.ex) 725 | $Vista = ($winID -And $NT6 -And -Not $NT7) 726 | $NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001) 727 | $win8 = ($strSLP -EQ $wslp -And $NT8) 728 | $reapp = ("Windows", "App")[!$winID] 729 | $prmnt = ("machine", "product")[!$winPR] 730 | 731 | if ($Description.Contains("VOLUME_KMSCLIENT")) {$cKmsClient = 1; $actTag = "Volume"} 732 | if ($Description.Contains("TIMEBASED_")) {$cTblClient = 1; $actTag = "Timebased"} 733 | if ($Description.Contains("VIRTUAL_MACHINE_ACTIVATION")) {$cAvmClient = 1; $actTag = "Automatic VM"} 734 | if ($null -EQ $cKmsClient -And $Description.Contains("VOLUME_KMS")) {$cKmsServer = 1} 735 | 736 | $gprDay = [Math]::Round($gprMnt/1440) 737 | $_xpr = "" 738 | $inGrace = $false 739 | if ($gprMnt -GT 0) { 740 | $_xpr = [DateTime]::Now.AddMinutes($gprMnt).ToString('yyyy-MM-dd hh:mm:ss tt') 741 | $inGrace = $true 742 | } 743 | 744 | $LicenseMsg = "Time remaining: $gprMnt minute(s) ($gprDay day(s))" 745 | if ($LicenseStatus -EQ 0) { 746 | $LicenseInf = "Unlicensed" 747 | $LicenseMsg = $null 748 | } 749 | if ($LicenseStatus -EQ 1) { 750 | $LicenseInf = "Licensed" 751 | if ($gprMnt -EQ 0) { 752 | $LicenseMsg = $null 753 | $ExpireMsg = "The $prmnt is permanently activated." 754 | } else { 755 | $LicenseMsg = "$actTag activation expiration: $gprMnt minute(s) ($gprDay day(s))" 756 | if ($inGrace) {$ExpireMsg = "$actTag activation will expire $_xpr"} 757 | } 758 | } 759 | if ($LicenseStatus -EQ 2) { 760 | $LicenseInf = "Initial grace period" 761 | if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"} 762 | } 763 | if ($LicenseStatus -EQ 3) { 764 | $LicenseInf = "Additional grace period (KMS license expired or hardware out of tolerance)" 765 | if ($inGrace) {$ExpireMsg = "Additional grace period ends $_xpr"} 766 | } 767 | if ($LicenseStatus -EQ 4) { 768 | $LicenseInf = "Non-genuine grace period" 769 | if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"} 770 | } 771 | if ($LicenseStatus -EQ 5 -And -Not $NT5) { 772 | $LicenseReason = '0x{0:X}' -f $LicReason 773 | $LicenseInf = "Notification" 774 | $LicenseMsg = "Notification Reason: $LicenseReason" 775 | if ($LicenseReason -EQ "0xC004F00F") {if ($null -NE $cKmsClient) {$LicenseMsg = $LicenseMsg + " (KMS license expired)."} else {$LicenseMsg = $LicenseMsg + " (hardware out of tolerance)."}} 776 | if ($LicenseReason -EQ "0xC004F200") {$LicenseMsg = $LicenseMsg + " (non-genuine)."} 777 | if ($LicenseReason -EQ "0xC004F009" -Or $LicenseReason -EQ "0xC004F064") {$LicenseMsg = $LicenseMsg + " (grace time expired)."} 778 | } 779 | if ($LicenseStatus -GT 5 -Or ($LicenseStatus -GT 4 -And $NT5)) { 780 | $LicenseInf = "Unknown" 781 | $LicenseMsg = $null 782 | } 783 | if ($LicenseStatus -EQ 6 -And -Not $Vista -And -Not $NT5) { 784 | $LicenseInf = "Extended grace period" 785 | if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"} 786 | } 787 | 788 | if ($isPPK) { 789 | $propPkey | foreach { set $_ (SlGetInfoPKey $pkid $_) } 790 | } 791 | 792 | if ($winPR -And $isPPK -And -Not $NT8) { 793 | $uxd = SlGetInfoSku $licID 'UXDifferentiator' 794 | $script:primary += @{ 795 | aid = $licID; 796 | ppk = $PartialProductKey; 797 | chn = $Channel; 798 | lst = $LicenseStatus; 799 | lcr = $LicReason; 800 | ged = $gprMnt; 801 | evl = $EvaluationEndDate; 802 | dff = $uxd 803 | } 804 | } 805 | 806 | if ($IID -And $isPPK) { 807 | $OfflineInstallationId = SlGetInfoIID $licID 808 | } 809 | 810 | if ($Dlv) { 811 | if ($win8) 812 | { 813 | $RemainingSkuReArmCount = SlGetInfoSku $licID 'RemainingRearmCount' 814 | $RemainingAppReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount' 815 | } 816 | else 817 | { 818 | if (($winID -And $NT7) -Or $strSLP -EQ $oslp) 819 | { 820 | $RemainingSLReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount' 821 | } 822 | else 823 | { 824 | $RemainingSLReArmCount = SlGetInfoService 'RearmCount' 825 | } 826 | } 827 | if ($null -EQ $TrustedTime) 828 | { 829 | $TrustedTime = SlGetInfoSvcApp $strApp 'TrustedTime' 830 | } 831 | } 832 | 833 | & $isAll 834 | CONOUT "Name: $Name" 835 | CONOUT "Description: $Description" 836 | CONOUT "Activation ID: $licID" 837 | if ($null -NE $DigitalPID) {CONOUT "Extended PID: $DigitalPID"} 838 | if ($null -NE $DigitalPID2 -And $Dlv) {CONOUT "Product ID: $DigitalPID2"} 839 | if ($null -NE $OfflineInstallationId -And $IID) {CONOUT "Installation ID: $OfflineInstallationId"} 840 | if ($null -NE $Channel) {CONOUT "Product Key Channel: $Channel"} 841 | if ($null -NE $PartialProductKey) {CONOUT "Partial Product Key: $PartialProductKey"} 842 | CONOUT "License Status: $LicenseInf" 843 | if ($null -NE $LicenseMsg) {CONOUT "$LicenseMsg"} 844 | if ($LicenseStatus -NE 0 -And $EvaluationEndDate) { 845 | $EED = [DateTime]::FromFileTimeUtc($EvaluationEndDate).ToString('yyyy-MM-dd hh:mm:ss tt') 846 | CONOUT "Evaluation End Date: $EED UTC" 847 | } 848 | if ($LicenseStatus -NE 1 -And $licPHN -NE "empty") { 849 | $gPHN = [String]::IsNullOrEmpty($licPHN) -NE $true 850 | CONOUT "Phone activatable: $($gPHN.ToString())" 851 | } 852 | if ($Dlv) { 853 | if ($null -NE $RemainingSLReArmCount) { 854 | CONOUT "Remaining $reapp rearm count: $RemainingSLReArmCount" 855 | } 856 | if ($null -NE $RemainingSkuReArmCount) { 857 | CONOUT "Remaining $reapp rearm count: $RemainingAppReArmCount" 858 | CONOUT "Remaining SKU rearm count: $RemainingSkuReArmCount" 859 | } 860 | if ($LicenseStatus -NE 0 -And $TrustedTime) { 861 | $TTD = [DateTime]::FromFileTime($TrustedTime).ToString('yyyy-MM-dd hh:mm:ss tt') 862 | CONOUT "Trusted time: $TTD" 863 | } 864 | } 865 | if (!$isPPK) { 866 | return 867 | } 868 | 869 | if ($win8 -And $VLActivationType -EQ 1) { 870 | DetectAdbaClient 871 | $cKmsClient = $null 872 | } 873 | 874 | if ($winID -And $null -NE $cAvmClient) { 875 | DetectAvmClient 876 | } 877 | 878 | $chkSub = ($winPR -And $isSub) 879 | 880 | $chkSLS = ($null -NE $cKmsClient -Or $null -NE $cKmsServer -Or $chkSub) 881 | 882 | if (!$chkSLS) { 883 | if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"} 884 | return 885 | } 886 | 887 | if ($null -NE $cKmsClient) { 888 | DetectKmsClient 889 | } 890 | 891 | if ($null -NE $cKmsServer) { 892 | if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"} 893 | DetectKmsHost 894 | } else { 895 | if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"} 896 | } 897 | 898 | if ($chkSub) { 899 | DetectSubscription 900 | } 901 | 902 | } 903 | 904 | function ParseList($strSLP, $strApp, $arrList) 905 | { 906 | foreach ($entry in $arrList) 907 | { 908 | GetResult $strSLP $strApp $entry 909 | CONOUT "$line3" 910 | & $noAll 911 | } 912 | } 913 | #endregion 914 | 915 | #region vNextDiag 916 | if ($PSVersionTable.PSVersion.Major -Lt 3) 917 | { 918 | function ConvertFrom-Json 919 | { 920 | [CmdletBinding()] 921 | Param( 922 | [Parameter(ValueFromPipeline=$true)][Object]$item 923 | ) 924 | [void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions") 925 | $psjs = New-Object System.Web.Script.Serialization.JavaScriptSerializer 926 | Return ,$psjs.DeserializeObject($item) 927 | } 928 | function ConvertTo-Json 929 | { 930 | [CmdletBinding()] 931 | Param( 932 | [Parameter(ValueFromPipeline=$true)][Object]$item 933 | ) 934 | [void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions") 935 | $psjs = New-Object System.Web.Script.Serialization.JavaScriptSerializer 936 | Return $psjs.Serialize($item) 937 | } 938 | } 939 | 940 | function PrintModePerPridFromRegistry 941 | { 942 | $vNextRegkey = "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext" 943 | $vNextPrids = Get-Item -Path $vNextRegkey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty 'property' -ErrorAction SilentlyContinue | Where-Object -FilterScript {$_.ToLower() -like "*retail" -or $_.ToLower() -like "*volume"} 944 | If ($null -Eq $vNextPrids) 945 | { 946 | CONOUT "`nNo registry keys found." 947 | Return 948 | } 949 | CONOUT "`r" 950 | $vNextPrids | ForEach ` 951 | { 952 | $mode = (Get-ItemProperty -Path $vNextRegkey -Name $_).$_ 953 | Switch ($mode) 954 | { 955 | 2 { $mode = "vNext"; Break } 956 | 3 { $mode = "Device"; Break } 957 | Default { $mode = "Legacy"; Break } 958 | } 959 | CONOUT "$_ = $mode" 960 | } 961 | } 962 | 963 | function PrintSharedComputerLicensing 964 | { 965 | $scaRegKey = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration" 966 | $scaValue = Get-ItemProperty -Path $scaRegKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction SilentlyContinue 967 | $scaRegKey2 = "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing" 968 | $scaValue2 = Get-ItemProperty -Path $scaRegKey2 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction SilentlyContinue 969 | $scaPolicyKey = "HKLM:\SOFTWARE\Policies\Microsoft\Office\16.0\Common\Licensing" 970 | $scaPolicyValue = Get-ItemProperty -Path $scaPolicyKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction SilentlyContinue 971 | If ($null -Eq $scaValue -And $null -Eq $scaValue2 -And $null -Eq $scaPolicyValue) 972 | { 973 | CONOUT "`nNo registry keys found." 974 | Return 975 | } 976 | $scaModeValue = $scaValue -Or $scaValue2 -Or $scaPolicyValue 977 | If ($scaModeValue -Eq 0) 978 | { 979 | $scaMode = "Disabled" 980 | } 981 | If ($scaModeValue -Eq 1) 982 | { 983 | $scaMode = "Enabled" 984 | } 985 | CONOUT "`nStatus: $scaMode" 986 | CONOUT "`r" 987 | $tokenFiles = $null 988 | $tokenPath = "${env:LOCALAPPDATA}\Microsoft\Office\16.0\Licensing" 989 | If (Test-Path $tokenPath) 990 | { 991 | $tokenFiles = Get-ChildItem -Path $tokenPath -Filter "*authString*" -Recurse | Where-Object { !$_.PSIsContainer } 992 | } 993 | If ($null -Eq $tokenFiles -Or $tokenFiles.Length -Eq 0) 994 | { 995 | CONOUT "No tokens found." 996 | Return 997 | } 998 | $tokenFiles | ForEach ` 999 | { 1000 | $tokenParts = (Get-Content -Encoding Unicode -Path $_.FullName).Split('_') 1001 | $output = New-Object PSObject 1002 | $output | Add-Member 8 'ACID' $tokenParts[0]; 1003 | $output | Add-Member 8 'User' $tokenParts[3]; 1004 | $output | Add-Member 8 'NotBefore' $tokenParts[4]; 1005 | $output | Add-Member 8 'NotAfter' $tokenParts[5]; 1006 | Write-Output $output 1007 | } 1008 | } 1009 | 1010 | function PrintLicensesInformation 1011 | { 1012 | Param( 1013 | [ValidateSet("NUL", "Device")] 1014 | [String]$mode 1015 | ) 1016 | If ($mode -Eq "NUL") 1017 | { 1018 | $licensePath = "${env:LOCALAPPDATA}\Microsoft\Office\Licenses" 1019 | } 1020 | ElseIf ($mode -Eq "Device") 1021 | { 1022 | $licensePath = "${env:PROGRAMDATA}\Microsoft\Office\Licenses" 1023 | } 1024 | $licenseFiles = $null 1025 | If (Test-Path $licensePath) 1026 | { 1027 | $licenseFiles = Get-ChildItem -Path $licensePath -Recurse | Where-Object { !$_.PSIsContainer } 1028 | } 1029 | If ($null -Eq $licenseFiles -Or $licenseFiles.Length -Eq 0) 1030 | { 1031 | CONOUT "`nNo licenses found." 1032 | Return 1033 | } 1034 | $licenseFiles | ForEach ` 1035 | { 1036 | $license = (Get-Content -Encoding Unicode $_.FullName | ConvertFrom-Json).License 1037 | $decodedLicense = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($license)) | ConvertFrom-Json 1038 | $licenseType = $decodedLicense.LicenseType 1039 | If ($null -Ne $decodedLicense.ExpiresOn) 1040 | { 1041 | $expiry = [System.DateTime]::Parse($decodedLicense.ExpiresOn, $null, 'AdjustToUniversal') 1042 | } 1043 | Else 1044 | { 1045 | $expiry = New-Object System.DateTime 1046 | } 1047 | $licenseState = "Grace" 1048 | If ((Get-Date) -Gt (Get-Date $decodedLicense.Metadata.NotAfter)) 1049 | { 1050 | $licenseState = "RFM" 1051 | } 1052 | ElseIf ((Get-Date) -Lt (Get-Date $expiry)) 1053 | { 1054 | $licenseState = "Licensed" 1055 | } 1056 | $output = New-Object PSObject 1057 | $output | Add-Member 8 'File' $_.PSChildName; 1058 | $output | Add-Member 8 'Version' $_.Directory.Name; 1059 | $output | Add-Member 8 'Type' "User|${licenseType}"; 1060 | $output | Add-Member 8 'Product' $decodedLicense.ProductReleaseId; 1061 | $output | Add-Member 8 'Acid' $decodedLicense.Acid; 1062 | If ($mode -Eq "Device") { $output | Add-Member 8 'DeviceId' $decodedLicense.Metadata.DeviceId; } 1063 | $output | Add-Member 8 'LicenseState' $licenseState; 1064 | $output | Add-Member 8 'EntitlementStatus' $decodedLicense.Status; 1065 | $output | Add-Member 8 'EntitlementExpiration' ("N/A", $decodedLicense.ExpiresOn)[!($null -eq $decodedLicense.ExpiresOn)]; 1066 | $output | Add-Member 8 'ReasonCode' ("N/A", $decodedLicense.ReasonCode)[!($null -eq $decodedLicense.ReasonCode)]; 1067 | $output | Add-Member 8 'NotBefore' $decodedLicense.Metadata.NotBefore; 1068 | $output | Add-Member 8 'NotAfter' $decodedLicense.Metadata.NotAfter; 1069 | $output | Add-Member 8 'NextRenewal' $decodedLicense.Metadata.RenewAfter; 1070 | $output | Add-Member 8 'TenantId' ("N/A", $decodedLicense.Metadata.TenantId)[!($null -eq $decodedLicense.Metadata.TenantId)]; 1071 | #$output.PSObject.Properties | foreach { $ht = @{} } { $ht[$_.Name] = $_.Value } { $output = $ht | ConvertTo-Json } 1072 | Write-Output $output 1073 | } 1074 | } 1075 | 1076 | function vNextDiagRun 1077 | { 1078 | $fNUL = ([IO.Directory]::Exists("${env:LOCALAPPDATA}\Microsoft\Office\Licenses")) -and ([IO.Directory]::GetFiles("${env:LOCALAPPDATA}\Microsoft\Office\Licenses", "*", 1).Length -GT 0) 1079 | $fDev = ([IO.Directory]::Exists("${env:PROGRAMDATA}\Microsoft\Office\Licenses")) -and ([IO.Directory]::GetFiles("${env:PROGRAMDATA}\Microsoft\Office\Licenses", "*", 1).Length -GT 0) 1080 | $rPID = $null -NE (GP "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext" -EA 0 | select -Expand 'property' -EA 0 | where -Filter {$_.ToLower() -like "*retail" -or $_.ToLower() -like "*volume"}) 1081 | $rSCA = $null -NE (GP "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration" -EA 0 | select -Expand "SharedComputerLicensing" -EA 0) 1082 | $rSCL = $null -NE (GP "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing" -EA 0 | select -Expand "SharedComputerLicensing" -EA 0) 1083 | 1084 | if (($fNUL -Or $fDev -Or $rPID -Or $rSCA -Or $rSCL) -EQ $false) { 1085 | Return 1086 | } 1087 | 1088 | & $isAll 1089 | CONOUT "$line2" 1090 | CONOUT "=== Office vNext Status ===" 1091 | CONOUT "$line2" 1092 | CONOUT "`n========== Mode per ProductReleaseId ==========" 1093 | PrintModePerPridFromRegistry 1094 | CONOUT "`n========== Shared Computer Licensing ==========" 1095 | PrintSharedComputerLicensing 1096 | CONOUT "`n========== vNext licenses ===========" 1097 | PrintLicensesInformation -Mode "NUL" 1098 | CONOUT "`n========== Device licenses ==========" 1099 | PrintLicensesInformation -Mode "Device" 1100 | CONOUT "$line3" 1101 | CONOUT "`r" 1102 | } 1103 | #endregion 1104 | 1105 | #region clic 1106 | 1107 | <# 1108 | ;;; Source: https://github.com/asdcorp/clic 1109 | ;;; Powershell port: abbodi1406 1110 | 1111 | Copyright 2023 asdcorp 1112 | 1113 | Permission is hereby granted, free of charge, to any person obtaining a copy of 1114 | this software and associated documentation files (the "Software"), to deal in 1115 | the Software without restriction, including without limitation the rights to 1116 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 1117 | the Software, and to permit persons to whom the Software is furnished to do so, 1118 | subject to the following conditions: 1119 | 1120 | The above copyright notice and this permission notice shall be included in all 1121 | copies or substantial portions of the Software. 1122 | 1123 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1124 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 1125 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 1126 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 1127 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1128 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1129 | #> 1130 | 1131 | function InitializeDigitalLicenseCheck { 1132 | $CAB = [System.Reflection.Emit.CustomAttributeBuilder] 1133 | 1134 | $ICom = $Module.DefineType('EUM.IEUM', 'Public, Interface, Abstract, Import') 1135 | $ICom.SetCustomAttribute($CAB::new([System.Runtime.InteropServices.ComImportAttribute].GetConstructor(@()), @())) 1136 | $ICom.SetCustomAttribute($CAB::new([System.Runtime.InteropServices.GuidAttribute].GetConstructor(@([String])), @('F2DCB80D-0670-44BC-9002-CD18688730AF'))) 1137 | $ICom.SetCustomAttribute($CAB::new([System.Runtime.InteropServices.InterfaceTypeAttribute].GetConstructor(@([Int16])), @([Int16]1))) 1138 | 1139 | 1..4 | % { [void]$ICom.DefineMethod('VF'+$_, 'Public, Virtual, HideBySig, NewSlot, Abstract', 'Standard, HasThis', [Void], @()) } 1140 | [void]$ICom.DefineMethod('AcquireModernLicenseForWindows', 1478, 33, [Int32], @([Int32], [Int32].MakeByRefType())) 1141 | 1142 | $IEUM = $ICom.CreateType() 1143 | } 1144 | 1145 | function PrintStateData { 1146 | $pwszStateData = 0 1147 | $cbSize = 0 1148 | 1149 | if ($Win32::SLGetWindowsInformation( 1150 | "Security-SPP-Action-StateData", 1151 | [ref]$null, 1152 | [ref]$cbSize, 1153 | [ref]$pwszStateData 1154 | )) { 1155 | return $FALSE 1156 | } 1157 | 1158 | [string[]]$pwszStateString = $Marshal::PtrToStringUni($pwszStateData) -replace ";", "`n " 1159 | CONOUT (" $pwszStateString") 1160 | 1161 | $Marshal::FreeHGlobal($pwszStateData) 1162 | return $TRUE 1163 | } 1164 | 1165 | function PrintLastActivationHResult { 1166 | $pdwLastHResult = 0 1167 | $cbSize = 0 1168 | 1169 | if ($Win32::SLGetWindowsInformation( 1170 | "Security-SPP-LastWindowsActivationHResult", 1171 | [ref]$null, 1172 | [ref]$cbSize, 1173 | [ref]$pdwLastHResult 1174 | )) { 1175 | return $FALSE 1176 | } 1177 | 1178 | CONOUT (" LastActivationHResult=0x{0:x8}" -f $Marshal::ReadInt32($pdwLastHResult)) 1179 | 1180 | $Marshal::FreeHGlobal($pdwLastHResult) 1181 | return $TRUE 1182 | } 1183 | 1184 | function PrintLastActivationTime { 1185 | $pqwLastTime = 0 1186 | $cbSize = 0 1187 | 1188 | if ($Win32::SLGetWindowsInformation( 1189 | "Security-SPP-LastWindowsActivationTime", 1190 | [ref]$null, 1191 | [ref]$cbSize, 1192 | [ref]$pqwLastTime 1193 | )) { 1194 | return $FALSE 1195 | } 1196 | 1197 | $actTime = $Marshal::ReadInt64($pqwLastTime) 1198 | if ($actTime -ne 0) { 1199 | CONOUT (" LastActivationTime={0}" -f [DateTime]::FromFileTimeUtc($actTime).ToString("yyyy/MM/dd:HH:mm:ss")) 1200 | } 1201 | 1202 | $Marshal::FreeHGlobal($pqwLastTime) 1203 | return $TRUE 1204 | } 1205 | 1206 | function PrintIsWindowsGenuine { 1207 | $dwGenuine = 0 1208 | 1209 | if ($Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine)) { 1210 | return $FALSE 1211 | } 1212 | 1213 | if ($dwGenuine -lt 5) { 1214 | CONOUT (" IsWindowsGenuine={0}" -f $ppwszGenuineStates[$dwGenuine]) 1215 | } else { 1216 | CONOUT (" IsWindowsGenuine={0}" -f $dwGenuine) 1217 | } 1218 | 1219 | return $TRUE 1220 | } 1221 | 1222 | function PrintDigitalLicenseStatus { 1223 | try { 1224 | . InitializeDigitalLicenseCheck 1225 | $ComObj = New-Object -Com EditionUpgradeManagerObj.EditionUpgradeManager 1226 | } catch { 1227 | return $FALSE 1228 | } 1229 | 1230 | $parameters = 1, $null 1231 | 1232 | if ([EUM.IEUM].GetMethod("AcquireModernLicenseForWindows").Invoke($ComObj, $parameters)) { 1233 | return $FALSE 1234 | } 1235 | 1236 | $dwReturnCode = $parameters[1] 1237 | [bool]$bDigitalLicense = $FALSE 1238 | 1239 | $bDigitalLicense = (($dwReturnCode -ge 0) -and ($dwReturnCode -ne 1)) 1240 | CONOUT (" IsDigitalLicense={0}" -f (BoolToWStr $bDigitalLicense)) 1241 | 1242 | return $TRUE 1243 | } 1244 | 1245 | function PrintSubscriptionStatus { 1246 | $dwSupported = 0 1247 | 1248 | if ($winbuild -ge 15063) { 1249 | $pwszPolicy = "ConsumeAddonPolicySet" 1250 | } else { 1251 | $pwszPolicy = "Allow-WindowsSubscription" 1252 | } 1253 | 1254 | if ($Win32::SLGetWindowsInformationDWORD($pwszPolicy, [ref]$dwSupported)) { 1255 | return $FALSE 1256 | } 1257 | 1258 | CONOUT (" SubscriptionSupportedEdition={0}" -f (BoolToWStr $dwSupported)) 1259 | 1260 | $pStatus = $Marshal::AllocHGlobal($Marshal::SizeOf([Type]$SubStatus)) 1261 | if ($Win32::ClipGetSubscriptionStatus([ref]$pStatus)) { 1262 | return $FALSE 1263 | } 1264 | 1265 | $sStatus = [Activator]::CreateInstance($SubStatus) 1266 | $sStatus = $Marshal::PtrToStructure($pStatus, [Type]$SubStatus) 1267 | $Marshal::FreeHGlobal($pStatus) 1268 | 1269 | CONOUT (" SubscriptionEnabled={0}" -f (BoolToWStr $sStatus.dwEnabled)) 1270 | 1271 | if ($sStatus.dwEnabled -eq 0) { 1272 | return $TRUE 1273 | } 1274 | 1275 | CONOUT (" SubscriptionSku={0}" -f $sStatus.dwSku) 1276 | CONOUT (" SubscriptionState={0}" -f $sStatus.dwState) 1277 | 1278 | return $TRUE 1279 | } 1280 | 1281 | function ClicRun 1282 | { 1283 | & $isAll 1284 | CONOUT "Client Licensing Check information:" 1285 | 1286 | $null = PrintStateData 1287 | $null = PrintLastActivationHResult 1288 | $null = PrintLastActivationTime 1289 | $null = PrintIsWindowsGenuine 1290 | 1291 | if ($DllDigital) { 1292 | $null = PrintDigitalLicenseStatus 1293 | } 1294 | 1295 | if ($DllSubscription) { 1296 | $null = PrintSubscriptionStatus 1297 | } 1298 | 1299 | CONOUT "$line3" 1300 | & $noAll 1301 | } 1302 | #endregion 1303 | 1304 | #region clc 1305 | function clcGetExpireKrn 1306 | { 1307 | $tData = 0 1308 | $cData = 0 1309 | $bData = 0 1310 | 1311 | $hrRet = $Win32::SLGetWindowsInformation( 1312 | "Kernel-ExpirationDate", 1313 | [ref]$tData, 1314 | [ref]$cData, 1315 | [ref]$bData 1316 | ) 1317 | 1318 | if ($hrRet -Or !$cData -Or $tData -NE 3) 1319 | { 1320 | return $null 1321 | } 1322 | 1323 | $year = $Marshal::ReadInt16($bData, 0) 1324 | if ($year -EQ 0 -Or $year -EQ 1601) 1325 | { 1326 | $rData = $null 1327 | } 1328 | else 1329 | { 1330 | $rData = '{0}/{1}/{2}:{3}:{4}:{5}' -f $year, $Marshal::ReadInt16($bData, 2), $Marshal::ReadInt16($bData, 4), $Marshal::ReadInt16($bData, 6), $Marshal::ReadInt16($bData, 8), $Marshal::ReadInt16($bData, 10) 1331 | } 1332 | 1333 | #$Marshal::FreeHGlobal($bData) 1334 | return $rData 1335 | } 1336 | 1337 | function clcGetExpireSys 1338 | { 1339 | $kuser = $Marshal::ReadInt64((New-Object IntPtr(0x7FFE02C8))) 1340 | 1341 | if ($kuser -EQ 0) 1342 | { 1343 | return $null 1344 | } 1345 | 1346 | $rData = [DateTime]::FromFileTimeUtc($kuser).ToString('yyyy/MM/dd:HH:mm:ss') 1347 | return $rData 1348 | } 1349 | 1350 | function clcGetLicensingState($dwState) 1351 | { 1352 | if ($dwState -EQ 5) { 1353 | $dwState = 3 1354 | } elseif ($dwState -EQ 3 -Or $dwState -EQ 4 -Or $dwState -EQ 6) { 1355 | $dwState = 2 1356 | } elseif ($dwState -GT 6) { 1357 | $dwState = 4 1358 | } 1359 | 1360 | $rData = '{0}' -f $ppwszLicensingStates[$dwState] 1361 | return $rData 1362 | } 1363 | 1364 | function clcGetGenuineState($AppId) 1365 | { 1366 | $dwGenuine = 0 1367 | 1368 | if ($NT7) { 1369 | $hrRet = $Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine) 1370 | } else { 1371 | $hrRet = $Win32::SLIsGenuineLocal([ref][Guid]$AppId, [ref]$dwGenuine, 0) 1372 | } 1373 | 1374 | if ($hrRet) 1375 | { 1376 | $dwGenuine = 4 1377 | } 1378 | 1379 | if ($dwGenuine -LT 5) { 1380 | $rData = '{0}' -f $ppwszGenuineStates[$dwGenuine] 1381 | } else { 1382 | $rData = $dwGenuine 1383 | } 1384 | return $rData 1385 | } 1386 | 1387 | function ClcRun 1388 | { 1389 | $prs = $script:primary[0] 1390 | if ($null -EQ $prs) { 1391 | return 1392 | } 1393 | 1394 | $lState = clcGetLicensingState $prs.lst 1395 | $uState = clcGetGenuineState $winApp 1396 | $TbbKrn = clcGetExpireKrn 1397 | $TbbSys = clcGetExpireSys 1398 | if ($null -NE $TbbKrn) { 1399 | $ked = $TbbKrn 1400 | } elseif ($null -NE $TbbSys) { 1401 | $ked = $TbbSys 1402 | } 1403 | 1404 | & $isAll 1405 | CONOUT "Client Licensing Check information:" 1406 | 1407 | CONOUT (" AppId={0}" -f $winApp) 1408 | if ($prs.ged) { CONOUT (" GraceEndDate={0}" -f ([DateTime]::UtcNow.AddMinutes($prs.ged).ToString('yyyy/MM/dd:HH:mm:ss'))) } 1409 | if ($null -NE $ked) { CONOUT (" KernelTimebombDate={0}" -f $ked) } 1410 | CONOUT (" LastConsumptionReason=0x{0:x8}" -f $prs.lcr) 1411 | if ($prs.evl) { CONOUT (" LicenseExpirationDate={0}" -f ([DateTime]::FromFileTimeUtc($prs.evl).ToString('yyyy/MM/dd:HH:mm:ss'))) } 1412 | CONOUT (" LicenseState={0}" -f $lState) 1413 | CONOUT (" PartialProductKey={0}" -f $prs.ppk) 1414 | CONOUT (" ProductKeyType={0}" -f $prs.chn) 1415 | CONOUT (" SkuId={0}" -f $prs.aid) 1416 | CONOUT (" uxDifferentiator={0}" -f $prs.dff) 1417 | CONOUT (" IsWindowsGenuine={0}" -f $uState) 1418 | 1419 | CONOUT "$line3" 1420 | & $noAll 1421 | } 1422 | #endregion 1423 | 1424 | $Host.UI.RawUI.WindowTitle = "Check Activation Status" 1425 | if ($All.IsPresent) { 1426 | $B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B; 1427 | if (!$Pass.IsPresent) {clear;} 1428 | } 1429 | 1430 | $SysPath = "$env:SystemRoot\System32" 1431 | if (Test-Path "$env:SystemRoot\Sysnative\reg.exe") { 1432 | $SysPath = "$env:SystemRoot\Sysnative" 1433 | } 1434 | 1435 | $wslp = "SoftwareLicensingProduct" 1436 | $wsls = "SoftwareLicensingService" 1437 | $oslp = "OfficeSoftwareProtectionProduct" 1438 | $osls = "OfficeSoftwareProtectionService" 1439 | $winApp = "55c92734-d682-4d71-983e-d6ec3f16059f" 1440 | $o14App = "59a52881-a989-479d-af46-f275c6370663" 1441 | $o15App = "0ff1ce15-a989-479d-af46-f275c6370663" 1442 | $isSub = ($winbuild -GE 26000) -And (Select-String -Path "$SysPath\wbem\sppwmi.mof" -Encoding unicode -Pattern "SubscriptionType") 1443 | $DllDigital = ($winbuild -GE 14393) -And (Test-Path "$SysPath\EditionUpgradeManagerObj.dll") 1444 | $DllSubscription = ($winbuild -GE 14393) -And (Test-Path "$SysPath\Clipc.dll") 1445 | $VLActTypes = @("All", "AD", "KMS", "Token") 1446 | $OPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" 1447 | $SPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" 1448 | $SLKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL" 1449 | $NSKeyPath = "HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL" 1450 | $propPrd = 'Name', 'Description', 'TrustedTime', 'VLActivationType' 1451 | $propPkey = 'PartialProductKey', 'Channel', 'DigitalPID', 'DigitalPID2' 1452 | $propKMSServer = 'KeyManagementServiceCurrentCount', 'KeyManagementServiceTotalRequests', 'KeyManagementServiceFailedRequests', 'KeyManagementServiceUnlicensedRequests', 'KeyManagementServiceLicensedRequests', 'KeyManagementServiceOOBGraceRequests', 'KeyManagementServiceOOTGraceRequests', 'KeyManagementServiceNonGenuineGraceRequests', 'KeyManagementServiceNotificationRequests' 1453 | $propKMSClient = 'CustomerPID', 'KeyManagementServiceName', 'KeyManagementServicePort', 'DiscoveredKeyManagementServiceName', 'DiscoveredKeyManagementServicePort', 'DiscoveredKeyManagementServiceIpAddress', 'VLActivationInterval', 'VLRenewalInterval', 'KeyManagementServiceLookupDomain' 1454 | $propKMSVista = 'CustomerPID', 'KeyManagementServiceName', 'VLActivationInterval', 'VLRenewalInterval' 1455 | $propADBA = 'ADActivationObjectName', 'ADActivationObjectDN', 'ADActivationCsvlkPID', 'ADActivationCsvlkSkuID' 1456 | $propAVMA = 'InheritedActivationId', 'InheritedActivationHostMachineName', 'InheritedActivationHostDigitalPid2', 'InheritedActivationActivationTime' 1457 | $primary = @() 1458 | $ppwszGenuineStates = @( 1459 | "SL_GEN_STATE_IS_GENUINE", 1460 | "SL_GEN_STATE_INVALID_LICENSE", 1461 | "SL_GEN_STATE_TAMPERED", 1462 | "SL_GEN_STATE_OFFLINE", 1463 | "SL_GEN_STATE_LAST" 1464 | ) 1465 | $ppwszLicensingStates = @( 1466 | "SL_LICENSING_STATUS_UNLICENSED", 1467 | "SL_LICENSING_STATUS_LICENSED", 1468 | "SL_LICENSING_STATUS_IN_GRACE_PERIOD", 1469 | "SL_LICENSING_STATUS_NOTIFICATION", 1470 | "SL_LICENSING_STATUS_LAST" 1471 | ) 1472 | 1473 | 'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ @()} 1474 | 1475 | $offsvc = "osppsvc" 1476 | if ($NT7 -Or -Not $NT6) {$winsvc = "sppsvc"} else {$winsvc = "slsvc"} 1477 | 1478 | try {gsv $winsvc -EA 1 | Out-Null; $WsppHook = 1} catch {$WsppHook = 0} 1479 | try {gsv $offsvc -EA 1 | Out-Null; $OsppHook = 1} catch {$OsppHook = 0} 1480 | 1481 | if (Test-Path "$SysPath\sppc.dll") { 1482 | $SLdll = 'sppc.dll' 1483 | } elseif (Test-Path "$SysPath\slc.dll") { 1484 | $SLdll = 'slc.dll' 1485 | } else { 1486 | $WsppHook = 0 1487 | } 1488 | 1489 | if ($OsppHook -NE 0) { 1490 | $OLdll = (strGetRegistry $OPKeyPath "Path") + 'osppc.dll' 1491 | if (!(Test-Path "$OLdll")) {$OsppHook = 0} 1492 | } 1493 | 1494 | if ($WsppHook -NE 0) { 1495 | if ($NT6 -And -Not $NT7 -And -Not $Admin) { 1496 | if ($null -EQ [Diagnostics.Process]::GetProcessesByName("$winsvc")[0].ProcessName) {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n"} 1497 | } else { 1498 | try {sasv $winsvc -EA 1} catch {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n"} 1499 | } 1500 | } 1501 | 1502 | if ($WsppHook -NE 0) { 1503 | . InitializePInvoke $SLdll $false 1504 | $hSLC = 0 1505 | [void]$Win32::SLOpen([ref]$hSLC) 1506 | 1507 | $cW1nd0ws = SlGetInfoSLID $winApp 1508 | $c0ff1ce15 = SlGetInfoSLID $o15App 1509 | $c0ff1ce14 = SlGetInfoSLID $o14App 1510 | } 1511 | 1512 | if ($cW1nd0ws.Count -GT 0) 1513 | { 1514 | echoWindows 1515 | ParseList $wslp $winApp $cW1nd0ws 1516 | } 1517 | elseif ($NT6) 1518 | { 1519 | echoWindows 1520 | CONOUT "Error: product key not found.`n" 1521 | } 1522 | 1523 | if ($NT6 -And -Not $NT8) { 1524 | ClcRun 1525 | } 1526 | 1527 | if ($NT8) { 1528 | ClicRun 1529 | } 1530 | 1531 | $doMSG = 1 1532 | 1533 | if ($c0ff1ce15.Count -GT 0) 1534 | { 1535 | CheckOhook 1536 | echoOffice 1537 | ParseList $wslp $o15App $c0ff1ce15 1538 | } 1539 | 1540 | if ($c0ff1ce14.Count -GT 0) 1541 | { 1542 | echoOffice 1543 | ParseList $wslp $o14App $c0ff1ce14 1544 | } 1545 | 1546 | if ($hSLC) { 1547 | [void]$Win32::SLClose($hSLC) 1548 | } 1549 | 1550 | if ($OsppHook -NE 0) { 1551 | try {sasv $offsvc -EA 1} catch {$OsppHook = 0; CONOUT "`nError: failed to start $offsvc Service.`n"} 1552 | } 1553 | 1554 | if ($OsppHook -NE 0) { 1555 | . InitializePInvoke "$OLdll" $true 1556 | $hSLC = 0 1557 | [void]$Win32::SLOpen([ref]$hSLC) 1558 | 1559 | $ospp15 = SlGetInfoSLID $o15App 1560 | $ospp14 = SlGetInfoSLID $o14App 1561 | } 1562 | 1563 | if ($ospp15.Count -GT 0) 1564 | { 1565 | echoOffice 1566 | ParseList $oslp $o15App $ospp15 1567 | } 1568 | 1569 | if ($ospp14.Count -GT 0) 1570 | { 1571 | echoOffice 1572 | ParseList $oslp $o14App $ospp14 1573 | } 1574 | 1575 | if ($hSLC) { 1576 | [void]$Win32::SLClose($hSLC) 1577 | } 1578 | 1579 | if ($NT7) { 1580 | vNextDiagRun 1581 | } 1582 | 1583 | ExitScript 0 1584 | :sppmgr: 1585 | -------------------------------------------------------------------------------- /MAS/Separate-Files-Version/Change_Windows_Edition.cmd: -------------------------------------------------------------------------------- 1 | @set masver=3.9 2 | @echo off 3 | 4 | 5 | 6 | ::============================================================================ 7 | :: 8 | :: Homepage: m{}assgrave{dot}dev 9 | :: 10 | ::============================================================================ 11 | 12 | 13 | 14 | :: To stage current edition while changing edition with CBS Upgrade Method, change 0 to 1 in below line 15 | set _stg=0 16 | 17 | 18 | 19 | ::======================================================================================================================================== 20 | 21 | :: Set environment variables, it helps if they are misconfigured in the system 22 | 23 | setlocal EnableExtensions 24 | setlocal DisableDelayedExpansion 25 | 26 | set "PathExt=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC" 27 | 28 | set "SysPath=%SystemRoot%\System32" 29 | set "Path=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" 30 | if exist "%SystemRoot%\Sysnative\reg.exe" ( 31 | set "SysPath=%SystemRoot%\Sysnative" 32 | set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%" 33 | ) 34 | 35 | set "ComSpec=%SysPath%\cmd.exe" 36 | set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" 37 | 38 | set re1= 39 | set re2= 40 | set "_cmdf=%~f0" 41 | for %%# in (%*) do ( 42 | if /i "%%#"=="re1" set re1=1 43 | if /i "%%#"=="re2" set re2=1 44 | if /i "%%#"=="-qedit" (set re1=1&set re2=1) 45 | ) 46 | 47 | :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows 48 | :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows 49 | 50 | if exist %SystemRoot%\Sysnative\cmd.exe if not defined re1 ( 51 | setlocal EnableDelayedExpansion 52 | start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* re1" 53 | exit /b 54 | ) 55 | 56 | :: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows 57 | 58 | if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined re2 ( 59 | setlocal EnableDelayedExpansion 60 | start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* re2" 61 | exit /b 62 | ) 63 | 64 | ::======================================================================================================================================== 65 | 66 | set "blank=" 67 | set "mas=ht%blank%tps%blank%://m%blank%ass%blank%grave.dev/" 68 | set "github=ht%blank%tps%blank%://github.com/m%blank%assgra%blank%vel/Micro%blank%soft-Acti%blank%vation-Scripts" 69 | set "selfgit=ht%blank%tps%blank%://git.acti%blank%vated.win/Micr%blank%osoft-Act%blank%ivation-Scripts" 70 | 71 | :: Check if Null service is working, it's important for the batch script 72 | 73 | sc query Null | find /i "RUNNING" 74 | if %errorlevel% NEQ 0 ( 75 | echo: 76 | echo Null service is not running, script may crash... 77 | echo: 78 | echo: 79 | echo Check this webpage for help - %mas%fix_service 80 | echo: 81 | echo: 82 | ping 127.0.0.1 -n 20 83 | ) 84 | cls 85 | 86 | :: Check LF line ending 87 | 88 | pushd "%~dp0" 89 | >nul findstr /v "$" "%~nx0" && ( 90 | echo: 91 | echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. 92 | echo: 93 | echo: 94 | echo Check this webpage for help - %mas%troubleshoot 95 | echo: 96 | echo: 97 | ping 127.0.0.1 -n 20 >nul 98 | popd 99 | exit /b 100 | ) 101 | popd 102 | 103 | ::======================================================================================================================================== 104 | 105 | cls 106 | color 07 107 | title Change Windows Edition %masver% 108 | 109 | set _args= 110 | set _elev= 111 | set _unattended=0 112 | 113 | set _args=%* 114 | if defined _args set _args=%_args:"=% 115 | if defined _args set _args=%_args:re1=% 116 | if defined _args set _args=%_args:re2=% 117 | if defined _args ( 118 | for %%A in (%_args%) do ( 119 | if /i "%%A"=="-el" set _elev=1 120 | ) 121 | ) 122 | 123 | set "nul1=1>nul" 124 | set "nul2=2>nul" 125 | set "nul6=2^>nul" 126 | set "nul=>nul 2>&1" 127 | 128 | call :dk_setvar 129 | set "line=echo ___________________________________________________________________________________________" 130 | 131 | ::======================================================================================================================================== 132 | 133 | if %winbuild% EQU 1 ( 134 | %eline% 135 | echo Failed to detect Windows build number. 136 | echo: 137 | setlocal EnableDelayedExpansion 138 | set fixes=%fixes% %mas%troubleshoot 139 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" 140 | goto dk_done 141 | ) 142 | 143 | if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( 144 | sc query gcs | find /i "RUNNING" %nul% && ( 145 | %eline% 146 | echo Windows Sandbox detected. 147 | echo The script cannot run due to missing licensing components. Aborting... 148 | echo: 149 | goto dk_done 150 | ) 151 | ) 152 | 153 | if %winbuild% LSS 7600 ( 154 | %eline% 155 | echo Unsupported OS version detected [%winbuild%]. 156 | echo This option is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. 157 | goto dk_done 158 | ) 159 | 160 | ::======================================================================================================================================== 161 | 162 | :: Fix special character limitations in path name 163 | 164 | set "_work=%~dp0" 165 | if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%" 166 | 167 | set "_batf=%~f0" 168 | set "_batp=%_batf:'=''%" 169 | 170 | set _PSarg="""%~f0""" -el %_args% 171 | set _PSarg=%_PSarg:'=''% 172 | 173 | set "_ttemp=%userprofile%\AppData\Local\Temp" 174 | 175 | setlocal EnableDelayedExpansion 176 | 177 | ::======================================================================================================================================== 178 | 179 | echo "!_batf!" | find /i "!_ttemp!" %nul1% && ( 180 | if /i not "!_work!"=="!_ttemp!" ( 181 | %eline% 182 | echo The script was launched from the temp folder. 183 | echo You are most likely running the script directly from the archive file. 184 | echo: 185 | echo Extract the archive file and launch the script from the extracted folder. 186 | goto dk_done 187 | ) 188 | ) 189 | 190 | ::======================================================================================================================================== 191 | 192 | :: Elevate script as admin and pass arguments and preventing loop 193 | 194 | %nul1% fltmc || ( 195 | if not defined _elev %psc% "start cmd.exe -arg '/c \"!_PSarg!\"' -verb runas" && exit /b 196 | %eline% 197 | echo This script needs admin rights. 198 | echo Right click on this script and select 'Run as administrator'. 199 | goto dk_done 200 | ) 201 | 202 | ::======================================================================================================================================== 203 | 204 | :: Check PowerShell 205 | 206 | ::pstst $ExecutionContext.SessionState.LanguageMode :pstst 207 | 208 | for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[System.IO.File]::ReadAllText('!_batp!') -split ':pstst';. ([scriptblock]::Create($f[1]))}" %nul6%') do (set tstresult=%%a) 209 | 210 | if /i not "%tstresult%"=="FullLanguage" ( 211 | %eline% 212 | for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a) 213 | echo Test 1 - %tstresult% 214 | echo Test 2 - !tstresult2! 215 | echo: 216 | 217 | REM check LanguageMode 218 | 219 | echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( 220 | echo FullLanguage mode not found in PowerShell. Aborting... 221 | echo If you have applied restrictions on Powershell then undo those changes. 222 | echo: 223 | set fixes=%fixes% %mas%fix_powershell 224 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell" 225 | goto dk_done 226 | ) 227 | 228 | REM check Powershell core version 229 | 230 | cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( 231 | echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... 232 | echo: 233 | set fixes=%fixes% %mas%in-place_repair_upgrade 234 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" 235 | goto dk_done 236 | ) 237 | 238 | REM check for Mal-ware that may cause issues with Powershell 239 | 240 | for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" ( 241 | echo "%%f" 242 | echo Mal%blank%ware found, PowerShell is not working properly. 243 | echo: 244 | set fixes=%fixes% %mas%remove_mal%w%ware 245 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" 246 | goto dk_done 247 | ) 248 | 249 | REM check if .NET is working properly 250 | 251 | if /i "!tstresult2!"=="FullLanguage" ( 252 | cmd /c "%psc% ""try {[System.AppDomain]::CurrentDomain.GetAssemblies(); [System.Math]::Sqrt(144)} catch {Exit 3}""" %nul% 253 | if !errorlevel!==3 ( 254 | echo Windows Powershell failed to load .NET command. Aborting... 255 | echo: 256 | set fixes=%fixes% %mas%in-place_repair_upgrade 257 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" 258 | goto dk_done 259 | ) 260 | ) 261 | 262 | REM check antivirus and other errors 263 | 264 | echo PowerShell is not working properly. Aborting... 265 | 266 | if /i "!tstresult2!"=="FullLanguage" ( 267 | echo: 268 | echo Your antivirus software might be blocking the script. 269 | echo: 270 | sc query sense | find /i "RUNNING" %nul% && ( 271 | echo Installed Antivirus - Microsoft Defender for Endpoint 272 | ) 273 | cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))}""" 274 | ) 275 | 276 | echo: 277 | set fixes=%fixes% %mas%troubleshoot 278 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" 279 | goto dk_done 280 | ) 281 | 282 | ::======================================================================================================================================== 283 | 284 | :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app 285 | 286 | if %winbuild% GEQ 17763 ( 287 | set terminal=1 288 | ) else ( 289 | set terminal= 290 | ) 291 | 292 | :: Check if script is running in Terminal app 293 | 294 | if defined terminal ( 295 | set lines=0 296 | for /f "skip=3 tokens=* delims=" %%A in ('mode con') do if "!lines!"=="0" ( 297 | for %%B in (%%A) do set lines=%%B 298 | ) 299 | if !lines! GEQ 100 set terminal= 300 | ) 301 | 302 | if %_unattended%==1 goto :skipQE 303 | for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) 304 | 305 | :: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app 306 | :: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes 307 | :: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error 308 | 309 | set resetQE=1 310 | reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0 311 | reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1% 312 | 313 | if defined terminal ( 314 | start conhost.exe "!_batf!" %_args% -qedit 315 | start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1% 316 | exit /b 317 | ) else if %resetQE% EQU 1 ( 318 | start cmd.exe /c ""!_batf!" %_args% -qedit" 319 | start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1% 320 | exit /b 321 | ) 322 | 323 | :skipQE 324 | 325 | ::======================================================================================================================================== 326 | 327 | :: Check for updates 328 | 329 | set -= 330 | set old= 331 | set pingp= 332 | set upver=%masver:.=% 333 | 334 | for %%A in ( 335 | activ%-%ated.win 336 | mass%-%grave.dev 337 | ) do if not defined pingp ( 338 | for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do ( 339 | if not "%%B"=="" (set old=1& set pingp=1) 340 | for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do ( 341 | if not "%%C"=="" set old= 342 | ) 343 | ) 344 | ) 345 | 346 | if defined old ( 347 | echo ________________________________________________ 348 | %eline% 349 | echo Your version of MAS [%masver%] is outdated. 350 | echo ________________________________________________ 351 | echo: 352 | if not %_unattended%==1 ( 353 | echo [1] Get Latest MAS 354 | echo [0] Continue Anyway 355 | echo: 356 | call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" 357 | choice /C:10 /N 358 | if !errorlevel!==2 rem 359 | if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b) 360 | ) 361 | ) 362 | 363 | ::======================================================================================================================================== 364 | 365 | setlocal DisableDelayedExpansion 366 | 367 | :: Check desktop location 368 | 369 | set desktop= 370 | for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') do call set "desktop=%%b" 371 | if not defined desktop for /f "delims=" %%a in ('%psc% "& {write-host $([Environment]::GetFolderPath('Desktop'))}"') do call set "desktop=%%a" 372 | 373 | if not defined desktop ( 374 | %eline% 375 | echo Unable to detect Desktop location, aborting... 376 | goto dk_done 377 | ) 378 | 379 | setlocal EnableDelayedExpansion 380 | 381 | ::======================================================================================================================================== 382 | 383 | cls 384 | if not defined terminal mode 98, 30 385 | title Change Windows Edition %masver% 386 | 387 | echo: 388 | echo Initializing... 389 | echo: 390 | 391 | for %%# in ( 392 | sppsvc.exe 393 | dism.exe 394 | ) do ( 395 | if not exist %SysPath%\%%# ( 396 | %eline% 397 | echo [%SysPath%\%%#] file is missing, aborting... 398 | echo: 399 | call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run DISM Restore and SFC Scan options." 400 | call :dk_color %Blue% "After that, restart system and try activation again." 401 | echo: 402 | set fixes=%fixes% %mas%in-place_repair_upgrade 403 | call :dk_color2 %Blue% "If it still shows the same error, do this - " %_Yellow% " %mas%in-place_repair_upgrade" 404 | goto dk_done 405 | ) 406 | ) 407 | 408 | ::======================================================================================================================================== 409 | 410 | set spp=SoftwareLicensingProduct 411 | set sps=SoftwareLicensingService 412 | 413 | call :dk_reflection 414 | call :dk_ckeckwmic 415 | call :dk_sppissue 416 | 417 | for /f "tokens=6-7 delims=[]. " %%i in ('ver') do if not "%%j"=="" ( 418 | set fullbuild=%%i.%%j 419 | ) else ( 420 | for /f "tokens=3" %%G in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR" %nul6%') do if not errorlevel 1 set /a "UBR=%%G" 421 | for /f "skip=2 tokens=3,4 delims=. " %%G in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildLabEx') do ( 422 | if defined UBR (set "fullbuild=%%G.!UBR!") else (set "fullbuild=%%G.%%H") 423 | ) 424 | ) 425 | 426 | ::======================================================================================================================================== 427 | 428 | :: Check Activation IDs 429 | 430 | call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f 431 | if not defined allapps ( 432 | %eline% 433 | echo Failed to find activation IDs. Aborting... 434 | echo: 435 | call :dk_color %Blue% "To fix this issue, activate Windows from the main menu." 436 | goto dk_done 437 | ) 438 | 439 | ::======================================================================================================================================== 440 | 441 | :: Check Windows Edition and branch 442 | 443 | set osedition= 444 | set dismnotworking= 445 | 446 | for /f "tokens=3 delims=: " %%a in ('DISM /English /Online /Get-CurrentEdition %nul6% ^| find /i "Current Edition :"') do set "osedition=%%a" 447 | if not defined osedition set dismnotworking=1 448 | 449 | if %_wmic% EQU 1 set "chkedi=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL) get LicenseFamily /VALUE" %nul6%')" 450 | if %_wmic% EQU 0 set "chkedi=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT LicenseFamily FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL').Get()).LicenseFamily ^| %% {echo ('LicenseFamily='+$_)}" %nul6%')" 451 | if not defined osedition %chkedi% do if not errorlevel 1 (call set "osedition=%%a") 452 | 453 | if not defined osedition ( 454 | %eline% 455 | echo Failed to detect OS edition, aborting... 456 | echo: 457 | call :dk_color %Blue% "To fix this issue, activate Windows from the main menu." 458 | goto dk_done 459 | ) 460 | 461 | for /f "skip=2 tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul6%') do set "regedition=%%a" 462 | if /i not "%osedition%"=="%regedition%" ( 463 | set "showeditionerror=call :dk_color %_Yellow% "[%osedition%] [Reg-%regedition%]."" 464 | ) 465 | 466 | set branch= 467 | for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildBranch %nul6%') do set "branch=%%b" 468 | 469 | ::======================================================================================================================================== 470 | 471 | :: Get target editions list 472 | 473 | set _target= 474 | set _dtarget= 475 | set _ptarget= 476 | set _ntarget= 477 | set _wtarget= 478 | 479 | if %winbuild% GEQ 10240 for /f "tokens=4" %%a in ('dism /online /english /Get-TargetEditions ^| findstr /i /c:"Target Edition : "') do (if defined _dtarget (set "_dtarget= !_dtarget! %%a ") else (set "_dtarget= %%a ")) 480 | if %winbuild% LSS 10240 for /f "tokens=4" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':cbsxml\:.*';. ([scriptblock]::Create($f[1])) -GetTargetEditions;" ^| findstr /i /c:"Target Edition : "') do (if defined _ptarget (set "_ptarget= !_ptarget! %%a ") else (set "_ptarget= %%a ")) 481 | 482 | if %winbuild% GEQ 10240 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" ( 483 | if %winbuild% GEQ 17063 call :ced_edilist 484 | if /i "%osedition:~0,4%"=="Core" set _pro=Professional 485 | if /i "%osedition%"=="CoreN" set _pro=ProfessionalN 486 | set "_dtarget= %_dtarget% !_wtarget! !_pro! " 487 | ) 488 | 489 | ::======================================================================================================================================== 490 | 491 | for %%# in (CloudEdition CloudEditionN ServerRdsh) do if /i %osedition%==%%# ( 492 | cls 493 | echo: 494 | call :dk_color %Red% "==== Note ====" 495 | echo: 496 | echo [EditionID:%osedition% ^| %fullbuild%] 497 | echo: 498 | echo Changing this edition may not remove "%osedition%"-specific features. 499 | echo: 500 | call :dk_color %_Yellow% "Press [7] to continue anyway..." 501 | choice /c 7 /n 502 | cls 503 | ) 504 | 505 | for %%# in ( %_dtarget% %_ptarget% ) do if /i not "%%#"=="%osedition%" ( 506 | echo "!_target!" | find /i " %%# " %nul1% || set "_target= !_target! %%# " 507 | ) 508 | 509 | if defined _target ( 510 | for %%# in (%_target%) do ( 511 | echo %%# | findstr /i "CountrySpecific CloudEdition" %nul% || (set "_ntarget=!_ntarget! %%#") 512 | ) 513 | ) 514 | 515 | if not defined _ntarget ( 516 | %line% 517 | echo: 518 | if defined dismnotworking call :dk_color %Red% "DISM.exe is not working." 519 | call :dk_color %Gray% "Target editions not found." 520 | echo Current Edition [%osedition% ^| %winbuild%] can not be changed to any other Edition. 521 | %line% 522 | goto dk_done 523 | ) 524 | 525 | ::======================================================================================================================================== 526 | 527 | :cedmenu2 528 | 529 | cls 530 | if not defined terminal mode 98, 30 531 | set inpt= 532 | set counter=0 533 | set verified=0 534 | set targetedition= 535 | 536 | %line% 537 | echo: 538 | call :dk_color %Gray% "You can change the edition [%osedition%] [%fullbuild%] to one of the following." 539 | %showeditionerror% 540 | if defined dismnotworking ( 541 | call :dk_color %_Yellow% "Note - DISM.exe is not working." 542 | if /i "%osedition:~0,4%"=="Core" call :dk_color %_Yellow% " - You will see more edition options to choose once its changed to Pro." 543 | ) 544 | %line% 545 | echo: 546 | 547 | for %%A in (%_ntarget%) do ( 548 | set /a counter+=1 549 | if /i %%A==IoTEnterprise ( 550 | echo [!counter!] %%A [GAC, not LTSC] 551 | ) else ( 552 | echo [!counter!] %%A 553 | ) 554 | set targetedition!counter!=%%A 555 | ) 556 | 557 | %line% 558 | echo: 559 | echo [0] %_exitmsg% 560 | echo: 561 | call :dk_color %_Green% "Enter an option number using your keyboard and press Enter to confirm:" 562 | set /p inpt= 563 | if "%inpt%"=="" goto cedmenu2 564 | if "%inpt%"=="0" exit /b 565 | for /l %%i in (1,1,%counter%) do (if "%inpt%"=="%%i" set verified=1) 566 | set targetedition=!targetedition%inpt%! 567 | if %verified%==0 goto cedmenu2 568 | 569 | ::======================================================================================================================================== 570 | 571 | if %winbuild% LSS 10240 goto :cbsmethod 572 | if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" goto :ced_change_server 573 | 574 | cls 575 | if not defined terminal mode con cols=105 lines=32 576 | 577 | if /i "%targetedition%"=="ServerRdsh" ( 578 | echo: 579 | call :dk_color %Red% "==== Note ====" 580 | echo: 581 | echo Once the edition is changed to "%targetedition%", 582 | echo the system may not be able to properly change edition later. 583 | echo: 584 | echo [1] Continue Anyway 585 | echo [0] Go Back 586 | echo: 587 | call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" 588 | choice /C:10 /N 589 | if !errorlevel!==2 goto cedmenu2 590 | if !errorlevel!==1 rem 591 | ) 592 | 593 | cls 594 | set key= 595 | set _chan= 596 | set _dismapi=0 597 | 598 | :: Check if DISM API or slmgr.vbs is required for edition upgrade 599 | 600 | if not exist "%SysPath%\spp\tokens\skus\%targetedition%\%targetedition%*.xrm-ms" ( 601 | echo %_wtarget% | find /i " %targetedition% " || ( 602 | set _dismapi=1 603 | ) 604 | ) 605 | 606 | set "keyflow=Retail OEM:NONSLP OEM:DM Volume:MAK Volume:GVLK PGS:TB Retail:TB:Eval" 607 | 608 | call :ced_targetSKU %targetedition% 609 | if defined targetSKU call :ced_windowskey 610 | if defined key if defined pkeychannel set _chan=%pkeychannel% 611 | if not defined key call :changeeditiondata 612 | if not defined key if %_dismapi%==1 if /i "%targetedition%"=="Professional" ( 613 | set key=VK7JG-NPHTM-C97JM-9MPGT-3V66T 614 | set _chan=Retail 615 | ) 616 | 617 | if not defined key ( 618 | %eline% 619 | echo [%targetedition% ^| %winbuild%] 620 | echo Failed to get product key from pkeyhelper.dll. 621 | echo: 622 | set fixes=%fixes% %mas%troubleshoot 623 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" 624 | goto dk_done 625 | ) 626 | 627 | ::======================================================================================================================================== 628 | 629 | :: Changing from Core to Non-Core & Changing editions in Windows build older than 17134 requires "changepk /productkey" or DISM Api method and restart 630 | :: In other cases, editions can be changed instantly with "slmgr /ipk" 631 | 632 | if %_dismapi%==1 ( 633 | if not defined terminal mode con cols=105 lines=40 634 | call :ced_rebootflag 635 | if defined rebootreq goto dk_done 636 | ) 637 | 638 | cls 639 | %line% 640 | echo: 641 | %showeditionerror% 642 | if defined dismnotworking call :dk_color %_Yellow% "DISM.exe is not working." 643 | echo Changing the current edition [%osedition%] %fullbuild% to [%targetedition%]... 644 | echo: 645 | 646 | if %_dismapi%==1 ( 647 | call :dk_color %Green% "Notes -" 648 | echo: 649 | echo - Save your work before continuing, the system will auto-restart. 650 | echo: 651 | echo - You will need to activate with HWID option once the edition is changed. 652 | %line% 653 | echo: 654 | choice /C:21 /N /M "[1] Continue [2] %_exitmsg% : " 655 | if !errorlevel!==1 exit /b 656 | ) 657 | 658 | ::======================================================================================================================================== 659 | 660 | if %_dismapi%==0 ( 661 | echo Installing %_chan% key [%key%] 662 | echo: 663 | if %_wmic% EQU 1 wmic path %sps% where __CLASS='%sps%' call InstallProductKey ProductKey="%key%" %nul% 664 | if %_wmic% EQU 0 %psc% "try { $null=(([WMISEARCHER]'SELECT Version FROM %sps%').Get()).InstallProductKey('%key%'); exit 0 } catch { exit $_.Exception.InnerException.HResult }" %nul% 665 | set keyerror=!errorlevel! 666 | cmd /c exit /b !keyerror! 667 | if !keyerror! NEQ 0 set "keyerror=[0x!=ExitCode!]" 668 | 669 | if !keyerror! EQU 0 ( 670 | call :dk_refresh 671 | call :dk_color %Green% "[Successful]" 672 | echo: 673 | call :dk_color %Gray% "Reboot is required to fully change the edition." 674 | ) else ( 675 | call :dk_color %Red% "[Unsuccessful] [Error Code: !keyerror!]" 676 | echo: 677 | set fixes=%fixes% %mas%troubleshoot 678 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" 679 | ) 680 | ) 681 | 682 | if %_dismapi%==1 ( 683 | echo: 684 | echo Applying the DISM API method with %_chan% key %key%. Please wait... 685 | echo: 686 | 687 | call :ced_prep 688 | if defined preperror goto dk_done 689 | 690 | %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':dismapi\:.*';. ([scriptblock]::Create($f[1])) %targetedition% %key%" 691 | call :ced_postprep 692 | ) 693 | %line% 694 | 695 | goto dk_done 696 | 697 | ::======================================================================================================================================== 698 | 699 | :cbsmethod 700 | 701 | cls 702 | if not defined terminal ( 703 | mode con cols=105 lines=32 704 | %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;}" %nul% 705 | ) 706 | 707 | call :ced_rebootflag 708 | if defined rebootreq goto dk_done 709 | 710 | echo: 711 | %showeditionerror% 712 | if defined dismnotworking call :dk_color %_Yellow% "Note - DISM.exe is not working." 713 | echo Changing the current edition [%osedition%] %fullbuild% to [%targetedition%]... 714 | echo: 715 | call :dk_color %Blue% "Important - Save your work before continuing, the system will auto-restart." 716 | echo: 717 | choice /C:01 /N /M "[1] Continue [0] %_exitmsg% : " 718 | if %errorlevel%==1 exit /b 719 | 720 | echo: 721 | echo Initializing... 722 | echo: 723 | 724 | call :ced_prep 725 | if defined preperror goto dk_done 726 | 727 | if %_stg%==0 (set stage=) else (set stage=-StageCurrent) 728 | %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':cbsxml\:.*';. ([scriptblock]::Create($f[1])) -SetEdition %targetedition% %stage%" 729 | call :ced_postprep 730 | %line% 731 | 732 | goto dk_done 733 | 734 | ::======================================================================================================================================== 735 | 736 | :ced_change_server 737 | 738 | cls 739 | if not defined terminal ( 740 | mode con cols=105 lines=32 741 | %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;}" %nul% 742 | ) 743 | 744 | set key= 745 | set _chan= 746 | set "keyflow=Volume:GVLK Retail Volume:MAK OEM:NONSLP OEM:DM PGS:TB Retail:TB:Eval" 747 | 748 | call :ced_targetSKU %targetedition% 749 | if defined targetSKU call :ced_windowskey 750 | if defined key if defined pkeychannel set _chan=%pkeychannel% 751 | if not defined key call :changeeditiondata 752 | 753 | if not defined key ( 754 | %eline% 755 | echo [%targetedition% ^| %winbuild%] 756 | echo Failed to get product key from pkeyhelper.dll. 757 | echo: 758 | set fixes=%fixes% %mas%troubleshoot 759 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" 760 | goto dk_done 761 | ) 762 | 763 | call :ced_rebootflag 764 | if defined rebootreq goto dk_done 765 | 766 | cls 767 | echo: 768 | %showeditionerror% 769 | if defined dismnotworking call :dk_color %_Yellow% "Note - DISM.exe is not working." 770 | echo Changing the current edition [%osedition%] %fullbuild% to [%targetedition%]... 771 | echo: 772 | 773 | call :ced_prep 774 | if defined preperror goto dk_done 775 | 776 | echo Applying the command with %_chan% key... 777 | echo DISM /online /Set-Edition:%targetedition% /ProductKey:%key% /AcceptEula 778 | DISM /online /Set-Edition:%targetedition% /ProductKey:%key% /AcceptEula 779 | 780 | call :ced_postprep 781 | %line% 782 | 783 | goto dk_done 784 | 785 | ::======================================================================================================================================== 786 | 787 | :ced_prep 788 | 789 | set _time= 790 | set preperror= 791 | 792 | for /f %%a in ('%psc% "(Get-Date).ToString('yyyyMMdd-HHmmssfff')"') do set _time=%%a 793 | 794 | %psc% Stop-Service TrustedInstaller -force %nul% 795 | 796 | sc query TrustedInstaller | find /i "RUNNING" %nul% && ( 797 | %eline% 798 | echo Failed to stop the TrustedInstaller service. 799 | echo Reboot your machine using the restart option and try again. 800 | set preperror=1 801 | exit /b 802 | ) 803 | 804 | copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "%SystemRoot%\logs\cbs\backup_cbs_%_time%.log" %nul% 805 | copy /y /b "%SystemRoot%\logs\DISM\dism.log" "%SystemRoot%\logs\DISM\backup_dism_%_time%.log" %nul% 806 | 807 | del /f /q "%SystemRoot%\logs\cbs\cbs.log" %nul% 808 | del /f /q "%SystemRoot%\logs\DISM\dism.log" %nul% 809 | 810 | :: Initiate this to appear in fresh logs 811 | 812 | dism /online /english /Get-CurrentEdition %nul% 813 | dism /online /english /Get-TargetEditions %nul% 814 | exit /b 815 | 816 | ::======================================================================================================================================== 817 | 818 | :ced_postprep 819 | 820 | timeout /t 5 %nul1% 821 | copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "%SystemRoot%\logs\cbs\cbs_%_time%.log" %nul% 822 | copy /y /b "%SystemRoot%\logs\DISM\dism.log" "%SystemRoot%\logs\DISM\dism_%_time%.log" %nul% 823 | 824 | if not exist "!desktop!\ChangeEdition_Logs\" md "!desktop!\ChangeEdition_Logs\" %nul% 825 | call :compresslog cbs\cbs_%_time%.log ChangeEdition_Logs\CBS %nul% 826 | call :compresslog DISM\dism_%_time%.log ChangeEdition_Logs\DISM %nul% 827 | 828 | echo: 829 | if %winbuild% GEQ 9200 %psc% "if ((Get-WindowsOptionalFeature -Online -FeatureName NetFx3).State -eq 'Enabled') {Write-Host 'Checking .NET Framework 3.5 Status - Enabled'}" 830 | echo Log files are copied to the ChangeEdition_Logs folder on your desktop. 831 | echo: 832 | call :dk_color %Blue% "In case there are errors, you should restart the system before trying again." 833 | echo: 834 | set fixes=%fixes% %mas%change_edition_issues 835 | call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%change_edition_issues" 836 | exit /b 837 | 838 | :compresslog 839 | 840 | :: https://stackoverflow.com/a/46268232 841 | 842 | set "ddf="%SystemRoot%\Temp\%Random%%Random%%Random%%Random%"" 843 | %nul% del /q /f %ddf% 844 | echo/.New Cabinet>%ddf% 845 | echo/.set Cabinet=ON>>%ddf% 846 | echo/.set CabinetFileCountThreshold=0;>>%ddf% 847 | echo/.set Compress=ON>>%ddf% 848 | echo/.set CompressionType=LZX>>%ddf% 849 | echo/.set CompressionLevel=7;>>%ddf% 850 | echo/.set CompressionMemory=21;>>%ddf% 851 | echo/.set FolderFileCountThreshold=0;>>%ddf% 852 | echo/.set FolderSizeThreshold=0;>>%ddf% 853 | echo/.set GenerateInf=OFF>>%ddf% 854 | echo/.set InfFileName=nul>>%ddf% 855 | echo/.set MaxCabinetSize=0;>>%ddf% 856 | echo/.set MaxDiskFileCount=0;>>%ddf% 857 | echo/.set MaxDiskSize=0;>>%ddf% 858 | echo/.set MaxErrors=1;>>%ddf% 859 | echo/.set RptFileName=nul>>%ddf% 860 | echo/.set UniqueFiles=ON>>%ddf% 861 | for /f "tokens=* delims=" %%D in ('dir /a:-D/b/s "%SystemRoot%\logs\%1"') do ( 862 | echo/"%%~fD" /inf=no;>>%ddf% 863 | ) 864 | makecab /F %ddf% /D DiskDirectory1="" /D CabinetNameTemplate="!desktop!\%2_%_time%.cab" 865 | del /q /f %ddf% 866 | exit /b 867 | 868 | ::======================================================================================================================================== 869 | 870 | :: Set variables 871 | 872 | :dk_setvar 873 | 874 | set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe 875 | set psc=%ps% -nop -c 876 | set winbuild=1 877 | for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" 878 | 879 | set _slexe=sppsvc.exe& set _slser=sppsvc 880 | if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc) 881 | if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc) 882 | if %_slexe%==SLsvc.exe set _vis=1 883 | 884 | set _NCS=1 885 | if %winbuild% LSS 10586 set _NCS=0 886 | if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) 887 | 888 | echo "%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%" | find /i "ARM64" %nul1% && (if %winbuild% LSS 21277 set ps32onArm=1) 889 | 890 | if %_NCS% EQU 1 ( 891 | for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" 892 | set "Red="41;97m"" 893 | set "Gray="100;97m"" 894 | set "Green="42;97m"" 895 | set "Blue="44;97m"" 896 | set "White="107;91m"" 897 | set "_Red="40;91m"" 898 | set "_White="40;37m"" 899 | set "_Green="40;92m"" 900 | set "_Yellow="40;93m"" 901 | ) else ( 902 | set "Red="Red" "white"" 903 | set "Gray="Darkgray" "white"" 904 | set "Green="DarkGreen" "white"" 905 | set "Blue="Blue" "white"" 906 | set "White="White" "Red"" 907 | set "_Red="Black" "Red"" 908 | set "_White="Black" "Gray"" 909 | set "_Green="Black" "Green"" 910 | set "_Yellow="Black" "Yellow"" 911 | ) 912 | 913 | set "nceline=echo: &echo ==== ERROR ==== &echo:" 914 | set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:" 915 | if %~z0 GEQ 200000 ( 916 | set "_exitmsg=Go back" 917 | set "_fixmsg=Go back to Main Menu, select Troubleshoot and run Fix Licensing option." 918 | ) else ( 919 | set "_exitmsg=Exit" 920 | set "_fixmsg=In MAS folder, run Troubleshoot script and select Fix Licensing option." 921 | ) 922 | exit /b 923 | 924 | ::======================================================================================================================================== 925 | 926 | :: Refresh license status 927 | 928 | :dk_refresh 929 | 930 | if %_wmic% EQU 1 wmic path %sps% where __CLASS='%sps%' call RefreshLicenseStatus %nul% 931 | if %_wmic% EQU 0 %psc% "$null=(([WMICLASS]'%sps%').GetInstances()).RefreshLicenseStatus()" %nul% 932 | exit /b 933 | 934 | :: Get all products Activation IDs 935 | 936 | :dk_actids 937 | 938 | set allapps= 939 | if %_wmic% EQU 1 set "chkapp=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='%1') get ID /VALUE" %nul6%')" 940 | if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT ID FROM %spp% WHERE ApplicationID=''%1''').Get()).ID ^| %% {echo ('ID='+$_)}" %nul6%')" 941 | %chkapp% do (if defined allapps (call set "allapps=!allapps! %%a") else (call set "allapps=%%a")) 942 | exit /b 943 | 944 | :: Get Edition list 945 | 946 | :ced_edilist 947 | 948 | if %_wmic% EQU 1 set "chkedi=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' AND LicenseDependsOn is NULL) get LicenseFamily /VALUE" %nul6%')" 949 | if %_wmic% EQU 0 set "chkedi=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT LicenseFamily FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND LicenseDependsOn is NULL').Get()).LicenseFamily ^| %% {echo ('LicenseFamily='+$_)}" %nul6%')" 950 | %chkedi% do call set "_wtarget= !_wtarget! %%a " 951 | exit /b 952 | 953 | :: Check wmic.exe 954 | 955 | :dk_ckeckwmic 956 | 957 | if %winbuild% LSS 9200 (set _wmic=1&exit /b) 958 | set _wmic=0 959 | for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( 960 | cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1 961 | ) 962 | exit /b 963 | 964 | :: Show info for potential script stuck scenario 965 | 966 | :dk_sppissue 967 | 968 | sc start %_slser% %nul% 969 | set spperror=%errorlevel% 970 | 971 | if %spperror% NEQ 1056 if %spperror% NEQ 0 ( 972 | %eline% 973 | echo sc start %_slser% [Error Code: %spperror%] 974 | if %spperror% EQU 1053 ( 975 | echo: 976 | call :dk_color %Blue% "Reboot your machine using the restart option and try again." 977 | call :dk_color %Blue% "If it still does not work, go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." 978 | ) 979 | ) 980 | 981 | echo: 982 | %psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host '%_slser% is not working correctly. Check this webpage for help - %mas%troubleshoot'}" 983 | exit /b 984 | 985 | :: Common lines used in PowerShell reflection code 986 | 987 | :dk_reflection 988 | 989 | set ref=$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1); 990 | set ref=%ref% $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False); 991 | set ref=%ref% $TypeBuilder = $ModuleBuilder.DefineType(0); 992 | exit /b 993 | 994 | ::======================================================================================================================================== 995 | 996 | :: Check pending reboot flags 997 | 998 | :ced_rebootflag 999 | 1000 | set rebootreq= 1001 | reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" %nul% && set rebootreq=1 1002 | reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" %nul% && set rebootreq=1 1003 | 1004 | if defined rebootreq ( 1005 | %eline% 1006 | echo Pending reboot flags found. 1007 | echo: 1008 | echo Make sure Windows is fully updated, restart the system and try again. 1009 | ) 1010 | exit /b 1011 | 1012 | ::======================================================================================================================================== 1013 | 1014 | :: Get Product Key from pkeyhelper.dll for future new editions 1015 | :: It works on Windows 10 1803 (17134) and later builds. 1016 | 1017 | :k_pkey 1018 | 1019 | call :dk_reflection 1020 | 1021 | set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('SkuGetProductKeyForEdition', 'pkeyhelper.dll', 'Public, Static', 1, [int], @([int], [String], [String].MakeByRefType(), [String].MakeByRefType()), 1, 3); 1022 | set d1=%d1% $out = ''; [void]$TypeBuilder.CreateType()::SkuGetProductKeyForEdition(%1, %2, [ref]$out, [ref]$null); $out 1023 | 1024 | set pkey= 1025 | for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkey=%%a) 1026 | exit /b 1027 | 1028 | :: Get channel name for the key which was extracted from pkeyhelper.dll 1029 | 1030 | :k_pkeychannel 1031 | 1032 | set k=%1 1033 | set m=[Runtime.InteropServices.Marshal] 1034 | set p=%SysPath%\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms 1035 | 1036 | set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('PidGenX', 'pidgenx.dll', 'Public, Static', 1, [int], @([String], [String], [String], [int], [IntPtr], [IntPtr], [IntPtr]), 1, 3); 1037 | set d1=%d1% $r = [byte[]]::new(0x04F8); $r[0] = 0xF8; $r[1] = 0x04; $f = %m%::AllocHGlobal(0x04F8); %m%::Copy($r, 0, $f, 0x04F8); 1038 | set d1=%d1% [void]$TypeBuilder.CreateType()::PidGenX('%k%', '%p%', '00000', 0, 0, 0, $f); %m%::Copy($f, $r, 0, 0x04F8); %m%::FreeHGlobal($f); [Text.Encoding]::Unicode.GetString($r, 1016, 128) 1039 | 1040 | set pkeychannel= 1041 | for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkeychannel=%%a) 1042 | exit /b 1043 | 1044 | :ced_windowskey 1045 | 1046 | for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b 1047 | for %%# in (%keyflow%) do ( 1048 | call :k_pkey %targetSKU% '%%#' 1049 | if defined pkey call :k_pkeychannel !pkey! 1050 | if /i "!pkeychannel!"=="%%#" ( 1051 | set key=!pkey! 1052 | exit /b 1053 | ) 1054 | ) 1055 | exit /b 1056 | 1057 | ::======================================================================================================================================== 1058 | 1059 | :ced_targetSKU 1060 | 1061 | set k=%1 1062 | set targetSKU= 1063 | for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b 1064 | 1065 | call :dk_reflection 1066 | 1067 | set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('GetEditionIdFromName', 'pkeyhelper.dll', 'Public, Static', 1, [int], @([String], [int].MakeByRefType()), 1, 3); 1068 | set d1=%d1% $out = 0; [void]$TypeBuilder.CreateType()::GetEditionIdFromName('%k%', [ref]$out); $out 1069 | 1070 | for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set targetSKU=%%a) 1071 | if "%targetSKU%"=="0" set targetSKU= 1072 | exit /b 1073 | 1074 | ::======================================================================================================================================== 1075 | 1076 | :dk_color 1077 | 1078 | if %_NCS% EQU 1 ( 1079 | echo %esc%[%~1%~2%esc%[0m 1080 | ) else if exist %ps% ( 1081 | %psc% write-host -back '%1' -fore '%2' '%3' 1082 | ) else if not exist %ps% ( 1083 | echo %~3 1084 | ) 1085 | exit /b 1086 | 1087 | :dk_color2 1088 | 1089 | if %_NCS% EQU 1 ( 1090 | echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m 1091 | ) else if exist %ps% ( 1092 | %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' 1093 | ) else if not exist %ps% ( 1094 | echo %~3 %~6 1095 | ) 1096 | exit /b 1097 | 1098 | ::======================================================================================================================================== 1099 | 1100 | :dk_done 1101 | 1102 | echo: 1103 | if %_unattended%==1 timeout /t 2 & exit /b 1104 | 1105 | if defined fixes ( 1106 | call :dk_color %White% "Follow ALL the ABOVE blue lines. " 1107 | call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" 1108 | choice /C:10 /N 1109 | if !errorlevel!==2 exit /b 1110 | if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) 1111 | ) 1112 | 1113 | if defined terminal ( 1114 | call :dk_color %_Yellow% "Press [0] key to %_exitmsg%..." 1115 | choice /c 0 /n 1116 | ) else ( 1117 | call :dk_color %_Yellow% "Press any key to %_exitmsg%..." 1118 | pause %nul1% 1119 | ) 1120 | 1121 | exit /b 1122 | 1123 | ::======================================================================================================================================== 1124 | 1125 | :: https://github.com/asdcorp/Set-WindowsCbsEdition 1126 | 1127 | :cbsxml:[ 1128 | param ( 1129 | [Parameter()] 1130 | [String]$SetEdition, 1131 | 1132 | [Parameter()] 1133 | [Switch]$GetTargetEditions, 1134 | 1135 | [Parameter()] 1136 | [Switch]$StageCurrent 1137 | ) 1138 | 1139 | function Get-AssemblyIdentity { 1140 | param ( 1141 | [String]$PackageName 1142 | ) 1143 | 1144 | $PackageName = [String]$PackageName 1145 | $packageData = ($PackageName -split '~') 1146 | 1147 | if($packageData[3] -eq '') { 1148 | $packageData[3] = 'neutral' 1149 | } 1150 | 1151 | return "" 1152 | } 1153 | 1154 | function Get-SxsName { 1155 | param ( 1156 | [String]$PackageName 1157 | ) 1158 | 1159 | $name = ($PackageName -replace '[^A-z0-9\-\._]', '') 1160 | 1161 | if($name.Length -gt 40) { 1162 | $name = ($name[0..18] -join '') + '\.\.' + ($name[-19..-1] -join '') 1163 | } 1164 | 1165 | return $name.ToLower() 1166 | } 1167 | 1168 | function Find-EditionXmlInSxs { 1169 | param ( 1170 | [String]$Edition 1171 | ) 1172 | 1173 | $candidates = @($Edition, 'Client', 'Server') 1174 | $winSxs = $Env:SystemRoot + '\WinSxS' 1175 | $allInSxs = Get-ChildItem -Path $winSxs | select Name 1176 | 1177 | foreach($candidate in $candidates) { 1178 | $name = Get-SxsName -PackageName "Microsoft-Windows-Editions-$candidate" 1179 | $packages = $allInSxs | where name -Match ('^.*_'+$name+'_31bf3856ad364e35') 1180 | 1181 | if($packages.Length -eq 0) { 1182 | continue 1183 | } 1184 | 1185 | $package = $packages[-1].Name 1186 | $testPath = $winSxs + "\$package\" + $Edition + 'Edition.xml' 1187 | 1188 | if(Test-Path -Path $testPath -PathType Leaf) { 1189 | return $testPath 1190 | } 1191 | } 1192 | 1193 | return $null 1194 | } 1195 | 1196 | function Find-EditionXml { 1197 | param ( 1198 | [String]$Edition 1199 | ) 1200 | 1201 | $servicingEditions = $Env:SystemRoot + '\servicing\Editions' 1202 | $editionXml = $Edition + 'Edition.xml' 1203 | 1204 | $editionXmlInServicing = $servicingEditions + '\' + $editionXml 1205 | 1206 | if(Test-Path -Path $editionXmlInServicing -PathType Leaf) { 1207 | return $editionXmlInServicing 1208 | } 1209 | 1210 | return Find-EditionXmlInSxs -Edition $Edition 1211 | } 1212 | 1213 | function Write-UpgradeCandidates { 1214 | param ( 1215 | [HashTable]$InstallCandidates 1216 | ) 1217 | 1218 | $editionCount = 0 1219 | Write-Host 'Editions that can be upgraded to:' 1220 | foreach($candidate in $InstallCandidates.Keys) { 1221 | Write-Host "Target Edition : $candidate" 1222 | $editionCount++ 1223 | } 1224 | 1225 | if($editionCount -eq 0) { 1226 | Write-Host '(no editions are available)' 1227 | } 1228 | } 1229 | 1230 | function Write-UpgradeXml { 1231 | param ( 1232 | [Array]$RemovalCandidates, 1233 | [Array]$InstallCandidates, 1234 | [Boolean]$Stage 1235 | ) 1236 | 1237 | $removeAction = 'remove' 1238 | if($Stage) { 1239 | $removeAction = 'stage' 1240 | } 1241 | 1242 | Write-Output '' 1243 | Write-Output '' 1244 | Write-Output '' 1245 | 1246 | foreach($package in $InstallCandidates) { 1247 | Write-Output '' 1248 | Write-Output (Get-AssemblyIdentity -PackageName $package) 1249 | Write-Output '' 1250 | } 1251 | 1252 | foreach($package in $RemovalCandidates) { 1253 | Write-Output "" 1254 | Write-Output (Get-AssemblyIdentity -PackageName $package) 1255 | Write-Output '' 1256 | } 1257 | 1258 | Write-Output '' 1259 | Write-Output '' 1260 | } 1261 | 1262 | function Write-Usage { 1263 | Get-Help $script:MyInvocation.MyCommand.Path -detailed 1264 | } 1265 | 1266 | $version = '1.0' 1267 | $getTargetsParam = $GetTargetEditions.IsPresent 1268 | $stageCurrentParam = $StageCurrent.IsPresent 1269 | 1270 | if($SetEdition -eq '' -and ($false -eq $getTargetsParam)) { 1271 | Write-Usage 1272 | Exit 1 1273 | } 1274 | 1275 | $removalCandidates = @(); 1276 | $installCandidates = @{}; 1277 | 1278 | $packages = Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages' | select Name | where { $_.name -match '^.*\\Microsoft-Windows-.*Edition~' } 1279 | foreach($package in $packages) { 1280 | $state = (Get-ItemProperty -Path "Registry::$($package.Name)").CurrentState 1281 | $packageName = ($package.Name -split '\\')[-1] 1282 | $packageEdition = (($packageName -split 'Edition~')[0] -split 'Microsoft-Windows-')[-1] 1283 | 1284 | if($state -eq 0x40) { 1285 | if($null -eq $installCandidates[$packageEdition]) { 1286 | $installCandidates[$packageEdition] = @() 1287 | } 1288 | 1289 | if($false -eq ($installCandidates[$packageEdition] -contains $packageName)) { 1290 | $installCandidates[$packageEdition] = $installCandidates[$packageEdition] + @($packageName) 1291 | } 1292 | } 1293 | 1294 | if((($state -eq 0x50) -or ($state -eq 0x70)) -and ($false -eq ($removalCandidates -contains $packageName))) { 1295 | $removalCandidates = $removalCandidates + @($packageName) 1296 | } 1297 | } 1298 | 1299 | if($getTargetsParam) { 1300 | Write-UpgradeCandidates -InstallCandidates $installCandidates 1301 | Exit 1302 | } 1303 | 1304 | if($false -eq ($installCandidates.Keys -contains $SetEdition)) { 1305 | Write-Error "The system cannot be upgraded to `"$SetEdition`"" 1306 | Exit 1 1307 | } 1308 | 1309 | $xmlPath = $Env:SystemRoot + '\Temp' + '\CbsUpgrade.xml' 1310 | 1311 | Write-UpgradeXml -RemovalCandidates $removalCandidates ` 1312 | -InstallCandidates $installCandidates[$SetEdition] ` 1313 | -Stage $stageCurrentParam >$xmlPath 1314 | 1315 | $editionXml = Find-EditionXml -Edition $SetEdition 1316 | if($null -eq $editionXml) { 1317 | Write-Warning 'Unable to find edition specific settings XML. Proceeding without it...' 1318 | } 1319 | 1320 | Write-Host 'Starting the upgrade process. This may take a while...' 1321 | 1322 | DISM.EXE /English /NoRestart /Online /Apply-Unattend:$xmlPath 1323 | $dismError = $LASTEXITCODE 1324 | 1325 | Remove-Item -Path $xmlPath -Force 1326 | 1327 | if(($dismError -ne 0) -and ($dismError -ne 3010)) { 1328 | Write-Error 'Failed to upgrade to the target edition' 1329 | Exit $dismError 1330 | } 1331 | 1332 | if($null -ne $editionXml) { 1333 | $destination = $Env:SystemRoot + '\' + $SetEdition + '.xml' 1334 | Copy-Item -Path $editionXml -Destination $destination 1335 | 1336 | DISM.EXE /English /NoRestart /Online /Apply-Unattend:$editionXml 1337 | $dismError = $LASTEXITCODE 1338 | 1339 | if(($dismError -ne 0) -and ($dismError -ne 3010)) { 1340 | Write-Error 'Failed to apply edition specific settings' 1341 | Exit $dismError 1342 | } 1343 | } 1344 | 1345 | Restart-Computer 1346 | :cbsxml:] 1347 | 1348 | ::======================================================================================================================================== 1349 | 1350 | :: Change edition using DISM API 1351 | :: Thanks to Alex (aka may, ave9858) 1352 | 1353 | :dismapi:[ 1354 | param ( 1355 | [Parameter()] 1356 | [String]$TargetEdition, 1357 | 1358 | [Parameter()] 1359 | [String]$Key 1360 | ) 1361 | 1362 | $AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1) 1363 | $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False) 1364 | $TB = $ModuleBuilder.DefineType(0) 1365 | 1366 | [void]$TB.DefinePInvokeMethod('DismInitialize', 'DismApi.dll', 22, 1, [int], @([int], [IntPtr], [IntPtr]), 1, 3) 1367 | [void]$TB.DefinePInvokeMethod('DismOpenSession', 'DismApi.dll', 22, 1, [int], @([String], [IntPtr], [IntPtr], [UInt32].MakeByRefType()), 1, 3) 1368 | [void]$TB.DefinePInvokeMethod('_DismSetEdition', 'DismApi.dll', 22, 1, [int], @([UInt32], [String], [String], [IntPtr], [IntPtr], [IntPtr]), 1, 3) 1369 | $Dism = $TB.CreateType() 1370 | 1371 | [void]$Dism::DismInitialize(2, 0, 0) 1372 | $Session = 0 1373 | [void]$Dism::DismOpenSession('DISM_{53BFAE52-B167-4E2F-A258-0A37B57FF845}', 0, 0, [ref]$Session) 1374 | if (!$Dism::_DismSetEdition($Session, "$TargetEdition", "$Key", 0, 0, 0)) { 1375 | Restart-Computer 1376 | } 1377 | :dismapi:] 1378 | 1379 | ::======================================================================================================================================== 1380 | 1381 | :: 1st column = Generic Retail/OEM/MAK/GVLK Key 1382 | :: 2nd column = Key Type 1383 | :: 3rd column = WMI Edition ID 1384 | :: 4th column = Version name incase same Edition ID is used in different OS versions with different key 1385 | :: Separator = _ 1386 | 1387 | :: For Windows 10/11 editions, HWID key is listed where ever possible, in Server versions, KMS key is listed where ever possible. 1388 | :: For Windows, generic keys are mentioned till 22000 and for Server, generic keys are mentioned till 17763, later ones are extracted from the pkeyhelper.dll 1389 | 1390 | :changeeditiondata 1391 | 1392 | if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" ( 1393 | if %winbuild% GTR 17763 exit /b 1394 | ) else ( 1395 | if %winbuild% GEQ 22000 exit /b 1396 | ) 1397 | if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*.mum" (set Cor=Cor) else (set Cor=) 1398 | 1399 | set w= 1400 | for %%# in ( 1401 | XGVPP-NMH47-7TTHJ-W3FW7-8HV%w%2C__OEM:NONSLP_Enterprise 1402 | D6RD9-D4N8T-RT9QX-YW6YT-FCW%w%WJ______Retail_Starter 1403 | 3V6Q6-NQXCX-V8YXR-9QCYV-QPF%w%CT__Volume:MAK_EnterpriseN 1404 | 3NFXW-2T27M-2BDW6-4GHRV-68X%w%RX______Retail_StarterN 1405 | VK7JG-NPHTM-C97JM-9MPGT-3V6%w%6T______Retail_Professional 1406 | 2B87N-8KFHP-DKV6R-Y2C8J-PKC%w%KT______Retail_ProfessionalN 1407 | 4CPRK-NM3K3-X6XXQ-RXX86-WXC%w%HW______Retail_CoreN 1408 | N2434-X9D7W-8PF6X-8DV9T-8TY%w%MD______Retail_CoreCountrySpecific 1409 | BT79Q-G7N6G-PGBYW-4YWX6-6F4%w%BT______Retail_CoreSingleLanguage 1410 | YTMG3-N6DKC-DKB77-7M9GH-8HV%w%X7______Retail_Core 1411 | XKCNC-J26Q9-KFHD2-FKTHY-KD7%w%2Y__OEM:NONSLP_PPIPro 1412 | YNMGQ-8RYV3-4PGQ3-C8XTP-7CF%w%BY______Retail_Education 1413 | 84NGF-MHBT6-FXBX8-QWJK7-DRR%w%8H______Retail_EducationN 1414 | KCNVH-YKWX8-GJJB9-H9FDT-6F7%w%W2__Volume:MAK_EnterpriseS_VB 1415 | 43TBQ-NH92J-XKTM7-KT3KK-P39%w%PB__OEM:NONSLP_EnterpriseS_RS5 1416 | NK96Y-D9CD8-W44CQ-R8YTK-DYJ%w%WX__OEM:NONSLP_EnterpriseS_RS1 1417 | FWN7H-PF93Q-4GGP8-M8RF3-MDW%w%WW__OEM:NONSLP_EnterpriseS_TH 1418 | RQFNW-9TPM3-JQ73T-QV4VQ-DV9%w%PT__Volume:MAK_EnterpriseSN_VB 1419 | M33WV-NHY3C-R7FPM-BQGPT-239%w%PG__Volume:MAK_EnterpriseSN_RS5 1420 | 2DBW3-N2PJG-MVHW3-G7TDK-9HK%w%R4__Volume:MAK_EnterpriseSN_RS1 1421 | NTX6B-BRYC2-K6786-F6MVQ-M7V%w%2X__Volume:MAK_EnterpriseSN_TH 1422 | G3KNM-CHG6T-R36X3-9QDG6-8M8%w%K9______Retail_ProfessionalSingleLanguage 1423 | HNGCC-Y38KG-QVK8D-WMWRK-X86%w%VK______Retail_ProfessionalCountrySpecific 1424 | DXG7C-N36C4-C4HTG-X4T3X-2YV%w%77______Retail_ProfessionalWorkstation 1425 | WYPNQ-8C467-V2W6J-TX4WX-WT2%w%RQ______Retail_ProfessionalWorkstationN 1426 | 8PTT6-RNW4C-6V7J2-C2D3X-MHB%w%PB______Retail_ProfessionalEducation 1427 | GJTYN-HDMQY-FRR76-HVGC7-QPF%w%8P______Retail_ProfessionalEducationN 1428 | C4NTJ-CX6Q2-VXDMR-XVKGM-F9D%w%JC__Volume:MAK_EnterpriseG 1429 | 46PN6-R9BK9-CVHKB-HWQ9V-MBJ%w%Y8__Volume:MAK_EnterpriseGN 1430 | NJCF7-PW8QT-3324D-688JX-2YV%w%66______Retail_ServerRdsh 1431 | XQQYW-NFFMW-XJPBH-K8732-CKF%w%FD______OEM:DM_IoTEnterprise 1432 | QPM6N-7J2WJ-P88HH-P3YRH-YY7%w%4H__OEM:NONSLP_IoTEnterpriseS 1433 | K9VKN-3BGWV-Y624W-MCRMQ-BHD%w%CD______Retail_CloudEditionN 1434 | KY7PN-VR6RX-83W6Y-6DDYQ-T6R%w%4W______Retail_CloudEdition 1435 | V3WVW-N2PV2-CGWC3-34QGF-VMJ%w%2C______Retail_Cloud 1436 | NH9J3-68WK7-6FB93-4K3DF-DJ4%w%F6______Retail_CloudN 1437 | 2HN6V-HGTM8-6C97C-RK67V-JQP%w%FD______Retail_CloudE 1438 | WC2BQ-8NRM3-FDDYY-2BFGV-KHK%w%QY_Volume:GVLK_ServerStandard%Cor%_RS1 1439 | CB7KF-BWN84-R7R2Y-793K2-8XD%w%DG_Volume:GVLK_ServerDatacenter%Cor%_RS1 1440 | JCKRF-N37P4-C2D82-9YXRT-4M6%w%3B_Volume:GVLK_ServerSolution_RS1 1441 | QN4C6-GBJD2-FB422-GHWJK-GJG%w%2R_Volume:GVLK_ServerCloudStorage_RS1 1442 | VP34G-4NPPG-79JTQ-864T4-R3M%w%QX_Volume:GVLK_ServerAzureCor_RS1 1443 | 9JQNQ-V8HQ6-PKB8H-GGHRY-R62%w%H6______Retail_ServerAzureNano_RS1 1444 | VN8D3-PR82H-DB6BJ-J9P4M-92F%w%6J______Retail_ServerStorageStandard_RS1 1445 | 48TQX-NVK3R-D8QR3-GTHHM-8FH%w%XC______Retail_ServerStorageWorkgroup_RS1 1446 | 2HXDN-KRXHB-GPYC7-YCKFJ-7FV%w%DG_Volume:GVLK_ServerDatacenterACor_RS3 1447 | PTXN8-JFHJM-4WC78-MPCBR-9W4%w%KR_Volume:GVLK_ServerStandardACor_RS3 1448 | ) do ( 1449 | for /f "tokens=1-4 delims=_" %%A in ("%%#") do if /i %targetedition%==%%C ( 1450 | 1451 | if not defined key ( 1452 | set 4th=%%D 1453 | if not defined 4th ( 1454 | set "key=%%A" & set "_chan=%%B" 1455 | ) else ( 1456 | echo "%branch%" | find /i "%%D" %nul1% && (set "key=%%A" & set "_chan=%%B") 1457 | ) 1458 | ) 1459 | ) 1460 | ) 1461 | exit /b 1462 | 1463 | ::======================================================================================================================================== 1464 | :: Leave empty line below 1465 | --------------------------------------------------------------------------------