├── .gitattributes ├── LICENSE ├── MAS ├── All-In-One-Version │ └── MAS_AIO-CRC32_31F7FD1E.cmd └── Separate-Files-Version │ ├── Activators │ ├── HWID_Activation.cmd │ ├── KMS38_Activation.cmd │ ├── Ohook_Activation_AIO.cmd │ ├── Online_KMS_Activation.cmd │ └── ReadMe.txt │ ├── Change_Edition.cmd │ ├── Check-Activation-Status-vbs.cmd │ ├── Check-Activation-Status-wmi.cmd │ ├── Extract_OEM_Folder.cmd │ ├── Troubleshoot.cmd │ └── _ReadMe.html └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # MAS export-ignore 2 | # LICENSE export-ignore 3 | # README.md export-ignore 4 | -------------------------------------------------------------------------------- /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 | 676 | -------------------------------------------------------------------------------- /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 | KMS38 - Windows 10-11-Server - Till the Year 2038 8 | Online KMS - Windows / Office - 180 Days. Lifetime With Renewal Task 9 | 10 | -------------------------------------------------------------------------------------- 11 | 12 | For more details, use the respective docs section here https://massgrave.dev/ -------------------------------------------------------------------------------- /MAS/Separate-Files-Version/Change_Edition.cmd: -------------------------------------------------------------------------------- 1 | @set masver=2.6 2 | @setlocal DisableDelayedExpansion 3 | @echo off 4 | 5 | 6 | 7 | ::============================================================================ 8 | :: 9 | :: This script is a part of 'Microsoft-Activation-Scripts' (MAS) project. 10 | :: 11 | :: Homepage: mass grave[.]dev 12 | :: Email: windowsaddict@protonmail.com 13 | :: 14 | ::============================================================================ 15 | 16 | 17 | 18 | :: To stage current edition while changing edition with CBS Upgrade Method, change 0 to 1 in below line 19 | set _stg=0 20 | 21 | 22 | 23 | ::======================================================================================================================================== 24 | 25 | :: Set Path variable, it helps if it is misconfigured in the system 26 | 27 | set "PATH=%SystemRoot%\System32;%SystemRoot%\System32\wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" 28 | if exist "%SystemRoot%\Sysnative\reg.exe" ( 29 | set "PATH=%SystemRoot%\Sysnative;%SystemRoot%\Sysnative\wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%PATH%" 30 | ) 31 | 32 | :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows 33 | :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows 34 | 35 | set "_cmdf=%~f0" 36 | for %%# in (%*) do ( 37 | if /i "%%#"=="r1" set r1=1 38 | if /i "%%#"=="r2" set r2=1 39 | if /i "%%#"=="-qedit" ( 40 | reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "1" /f %nul1% 41 | rem check the code below admin elevation to understand why it's here 42 | ) 43 | ) 44 | 45 | if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 ( 46 | setlocal EnableDelayedExpansion 47 | start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1" 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 r2 ( 54 | setlocal EnableDelayedExpansion 55 | start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* r2" 56 | exit /b 57 | ) 58 | 59 | ::======================================================================================================================================== 60 | 61 | set "blank=" 62 | set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" 63 | 64 | :: Check if Null service is working, it's important for the batch script 65 | 66 | sc query Null | find /i "RUNNING" 67 | if %errorlevel% NEQ 0 ( 68 | echo: 69 | echo Null service is not running, script may crash... 70 | echo: 71 | echo: 72 | echo Help - %mas%troubleshoot.html 73 | echo: 74 | echo: 75 | ping 127.0.0.1 -n 10 76 | ) 77 | cls 78 | 79 | :: Check LF line ending 80 | 81 | pushd "%~dp0" 82 | >nul findstr /v "$" "%~nx0" && ( 83 | echo: 84 | echo Error: Script either has LF line ending issue or an empty line at the end of the script is missing. 85 | echo: 86 | ping 127.0.0.1 -n 6 >nul 87 | popd 88 | exit /b 89 | ) 90 | popd 91 | 92 | ::======================================================================================================================================== 93 | 94 | cls 95 | color 07 96 | title Change Windows Edition %masver% 97 | 98 | set _args= 99 | set _elev= 100 | 101 | set _args=%* 102 | if defined _args set _args=%_args:"=% 103 | if defined _args ( 104 | for %%A in (%_args%) do ( 105 | if /i "%%A"=="-el" set _elev=1 106 | ) 107 | ) 108 | 109 | set "nul1=1>nul" 110 | set "nul2=2>nul" 111 | set "nul6=2^>nul" 112 | set "nul=>nul 2>&1" 113 | 114 | set psc=powershell.exe 115 | set winbuild=1 116 | for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G 117 | 118 | set _NCS=1 119 | if %winbuild% LSS 10586 set _NCS=0 120 | if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) 121 | 122 | if %_NCS% EQU 1 ( 123 | for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" 124 | set "Red="41;97m"" 125 | set "Gray="100;97m"" 126 | set "Green="42;97m"" 127 | set "Blue="44;97m"" 128 | set "_White="40;37m"" 129 | set "_Green="40;92m"" 130 | set "_Yellow="40;93m"" 131 | ) else ( 132 | set "Red="Red" "white"" 133 | set "Gray="Darkgray" "white"" 134 | set "Green="DarkGreen" "white"" 135 | set "Blue="Blue" "white"" 136 | set "_White="Black" "Gray"" 137 | set "_Green="Black" "Green"" 138 | set "_Yellow="Black" "Yellow"" 139 | ) 140 | 141 | set "nceline=echo: &echo ==== ERROR ==== &echo:" 142 | set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:" 143 | set "line=echo ___________________________________________________________________________________________" 144 | if %~z0 GEQ 200000 (set "_exitmsg=Go back") else (set "_exitmsg=Exit") 145 | 146 | ::======================================================================================================================================== 147 | 148 | if %winbuild% LSS 7600 ( 149 | %nceline% 150 | echo Unsupported OS version detected [%winbuild%]. 151 | echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalent. 152 | goto ced_done 153 | ) 154 | 155 | for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" ( 156 | %nceline% 157 | echo Unable to find powershell.exe in the system. 158 | goto ced_done 159 | ) 160 | 161 | ::======================================================================================================================================== 162 | 163 | :: Fix special characters limitation in path name 164 | 165 | set "_work=%~dp0" 166 | if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%" 167 | 168 | set "_batf=%~f0" 169 | set "_batp=%_batf:'=''%" 170 | 171 | set _PSarg="""%~f0""" -el %_args% 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 Script is launched from the temp folder, 183 | echo Most likely you are 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 ced_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 To do so, right click on this script and select 'Run as administrator'. 199 | goto ced_done 200 | ) 201 | 202 | ::======================================================================================================================================== 203 | 204 | :: This code disables QuickEdit for this cmd.exe session only without making permanent changes to the registry 205 | :: It is added because clicking on the script window pauses the operation and leads to the confusion that script stopped due to an error 206 | 207 | for %%# in (%_args%) do (if /i "%%#"=="-qedit" set quedit=1) 208 | 209 | reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% || if not defined quedit ( 210 | reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "0" /f %nul1% 211 | start cmd.exe /c ""!_batf!" %_args% -qedit" 212 | rem quickedit reset code is added at the starting of the script instead of here because it takes time to reflect in some cases 213 | exit /b 214 | ) 215 | 216 | ::======================================================================================================================================== 217 | 218 | :: Check for updates 219 | 220 | set -= 221 | set old= 222 | 223 | for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do ( 224 | if not [%%#]==[] (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1)) 225 | ) 226 | 227 | if defined old ( 228 | echo ________________________________________________ 229 | %eline% 230 | echo You are running outdated version MAS %masver% 231 | echo ________________________________________________ 232 | echo: 233 | echo [1] Get Latest MAS 234 | echo [0] Continue Anyway 235 | echo: 236 | call :dk_color %_Green% "Enter a menu option in the Keyboard [1,0] :" 237 | choice /C:10 /N 238 | if !errorlevel!==2 rem 239 | if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) 240 | ) 241 | 242 | ::======================================================================================================================================== 243 | 244 | cls 245 | mode 98, 30 246 | 247 | echo: 248 | echo Initializing... 249 | echo: 250 | call :dk_product 251 | call :dk_ckeckwmic 252 | 253 | :: Show info for potential script stuck scenario 254 | 255 | sc start sppsvc %nul% 256 | if %errorlevel% NEQ 1056 if %errorlevel% NEQ 0 ( 257 | echo: 258 | echo Error code: %errorlevel% 259 | call :dk_color %Red% "Failed to start [sppsvc] service, rest of the process may take a long time..." 260 | echo: 261 | ) 262 | 263 | ::======================================================================================================================================== 264 | 265 | :: Check Activation IDs 266 | 267 | call :dk_actids 268 | if not defined applist ( 269 | net stop sppsvc /y %nul% 270 | cscript //nologo %windir%\system32\slmgr.vbs /rilc %nul% 271 | if !errorlevel! NEQ 0 cscript //nologo %windir%\system32\slmgr.vbs /rilc %nul% 272 | call :dk_refresh 273 | call :dk_actids 274 | if not defined applist ( 275 | %eline% 276 | echo Activation IDs not found. Aborting... 277 | echo: 278 | echo Check this page for help. %mas%troubleshoot 279 | goto ced_done 280 | ) 281 | ) 282 | 283 | ::======================================================================================================================================== 284 | 285 | call :dk_checksku 286 | 287 | if not defined osSKU ( 288 | %eline% 289 | echo SKU value was not detected properly. Aborting... 290 | goto ced_done 291 | ) 292 | 293 | ::======================================================================================================================================== 294 | 295 | :: Check Windows Edition 296 | 297 | set osedition= 298 | set dismedition= 299 | set dismnotworking= 300 | 301 | set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [int], @([String], [int], [int].MakeByRefType(), [String].MakeByRefType()), 1, 3); 302 | set d1=%d1% $editionName = 0; [void]$TypeBuilder.CreateType()::SLGetWindowsInformation('Kernel-EditionName', 0, [ref]0, [ref]$editionName); $editionName 303 | if %winbuild% GEQ 14393 for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set osedition=%%s) 304 | if "%osedition%"=="0" set osedition= 305 | 306 | if not defined osedition ( 307 | for /f "skip=2 tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul6%') do set "osedition=%%a" 308 | ) 309 | 310 | :: Workaround for an issue in builds between 1607 and 1709 where ProfessionalEducation is shown as Professional 311 | 312 | if %osSKU%==164 set osedition=ProfessionalEducation 313 | if %osSKU%==165 set osedition=ProfessionalEducationN 314 | 315 | for /f "tokens=3 delims=: " %%a in ('DISM /English /Online /Get-CurrentEdition %nul6% ^| find /i "Current Edition :"') do set "dismedition=%%a" 316 | if not defined dismedition set dismnotworking=1 317 | 318 | if defined dismedition if not defined osedition set osedition=%dismedition% 319 | 320 | if not defined osedition ( 321 | %eline% 322 | DISM /English /Online /Get-CurrentEdition %nul% 323 | cmd /c exit /b !errorlevel! 324 | echo DISM command failed [Error Code - 0x!=ExitCode!] 325 | echo OS Edition was not detected properly. Aborting... 326 | echo: 327 | echo Check this page for help. %mas%troubleshoot 328 | goto ced_done 329 | ) 330 | 331 | ::======================================================================================================================================== 332 | 333 | set branch= 334 | for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildBranch %nul6%') do set "branch=%%b" 335 | 336 | :: Check PowerShell 337 | 338 | %psc% $ExecutionContext.SessionState.LanguageMode %nul2% | find /i "Full" %nul1% || ( 339 | %eline% 340 | %psc% $ExecutionContext.SessionState.LanguageMode 341 | echo: 342 | echo PowerShell is not working. Aborting... 343 | echo If you have applied restrictions on Powershell then undo those changes. 344 | echo: 345 | echo Check this page for help. %mas%troubleshoot 346 | goto ced_done 347 | ) 348 | 349 | ::======================================================================================================================================== 350 | 351 | :: Get Target editions list 352 | 353 | set _target= 354 | set _dtarget= 355 | set _ptarget= 356 | set _ntarget= 357 | set _wtarget= 358 | 359 | 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 ")) 360 | if %winbuild% LSS 10240 for /f "tokens=4" %%a in ('%psc% "$f=[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 ")) 361 | 362 | if %winbuild% GEQ 10240 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" ( 363 | call :ced_edilist 364 | if /i "%osedition:~0,4%"=="Core" (set "_wtarget= Professional !_wtarget! ") 365 | set "_dtarget= %_dtarget% !_wtarget! " 366 | ) 367 | 368 | ::======================================================================================================================================== 369 | 370 | :: Block the change to/from CloudEdition editions 371 | 372 | for %%# in (202 203) do if %osSKU%==%%# ( 373 | %eline% 374 | echo [%winos% ^| SKU:%osSKU% ^| %winbuild%] 375 | echo It's not recommended to change this installed edition to any other. 376 | echo Aborting... 377 | goto ced_done 378 | ) 379 | 380 | for %%# in ( %_dtarget% %_ptarget% ) do if /i not "%%#"=="%osedition%" ( 381 | echo "!_target!" | find /i " %%# " %nul1% || set "_target= !_target! %%# " 382 | ) 383 | 384 | if defined _target ( 385 | for %%# in (%_target%) do ( 386 | echo %%# | findstr /i "CountrySpecific CloudEdition ServerRdsh" %nul% || (set "_ntarget=!_ntarget! %%#") 387 | ) 388 | ) 389 | 390 | if not defined _ntarget ( 391 | %line% 392 | echo: 393 | if defined dismnotworking call :dk_color %Red% "DISM.exe is not responding." 394 | call :dk_color %Gray% "Target Edition not found." 395 | echo Current Edition [%osedition% ^| %winbuild%] can not be changed to any other Edition. 396 | %line% 397 | goto ced_done 398 | ) 399 | 400 | ::======================================================================================================================================== 401 | 402 | :cedmenu2 403 | 404 | cls 405 | mode 98, 30 406 | set inpt= 407 | set counter=0 408 | set verified=0 409 | set targetedition= 410 | 411 | %line% 412 | echo: 413 | call :dk_color %Gray% "You can change the Edition [%osedition%] [%winbuild%] to one of the following." 414 | if defined dismnotworking ( 415 | call :dk_color %_Yellow% "Note - DISM.exe is not responding." 416 | if /i "%osedition:~0,4%"=="Core" call :dk_color %_Yellow% " - You will see more edition options to choose once its changed to Pro." 417 | ) 418 | %line% 419 | echo: 420 | 421 | for %%A in (%_ntarget%) do ( 422 | set /a counter+=1 423 | echo [!counter!] %%A 424 | set targetedition!counter!=%%A 425 | ) 426 | 427 | %line% 428 | echo: 429 | echo [0] %_exitmsg% 430 | echo: 431 | call :dk_color %_Green% "Enter option number in keyboard, and press "Enter":" 432 | set /p inpt= 433 | if "%inpt%"=="" goto cedmenu2 434 | if "%inpt%"=="0" exit /b 435 | for /l %%i in (1,1,%counter%) do (if "%inpt%"=="%%i" set verified=1) 436 | set targetedition=!targetedition%inpt%! 437 | if %verified%==0 goto cedmenu2 438 | 439 | ::======================================================================================================================================== 440 | 441 | if %winbuild% LSS 10240 goto :cbsmethod 442 | if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" goto :ced_change_server 443 | 444 | cls 445 | mode con cols=105 lines=32 446 | 447 | set key= 448 | set _chan= 449 | set _dismapi=0 450 | 451 | :: Check if DISM Api or slmgr.vbs is required for edition upgrade 452 | 453 | if not exist "%SystemRoot%\System32\spp\tokens\skus\%targetedition%\" ( 454 | set _dismapi=1 455 | ) 456 | 457 | set "keyflow=Retail OEM:NONSLP OEM:DM Volume:MAK Volume:GVLK" 458 | 459 | call :ced_targetSKU %targetedition% 460 | if defined targetSKU call :ced_windowskey 461 | if defined key if defined pkeychannel set _chan=%pkeychannel% 462 | if not defined key call :changeeditiondata 463 | 464 | if not defined key ( 465 | %eline% 466 | echo [%targetedition% ^| %winbuild%] 467 | echo Unable to get product key from pkeyhelper.dll 468 | echo: 469 | echo Check this page for help. %mas%troubleshoot 470 | goto ced_done 471 | ) 472 | 473 | ::======================================================================================================================================== 474 | 475 | :: Changing from Core to Non-Core & Changing editions in Windows build older than 17134 requires "changepk /productkey" or DISM Api method and restart 476 | :: In other cases, editions can be changed instantly with "slmgr /ipk" 477 | 478 | if %_dismapi%==1 ( 479 | mode con cols=105 lines=40 480 | %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':checkrebootflag\:.*';iex ($f[1]);" | find /i "True" %nul% && ( 481 | %eline% 482 | echo Pending Reboot flags found. 483 | echo: 484 | echo Restart the system and try again. 485 | goto ced_done 486 | ) 487 | ) 488 | 489 | cls 490 | %line% 491 | echo: 492 | if defined dismnotworking call :dk_color %_Yellow% "DISM.exe is not responding." 493 | echo Changing the Current Edition [%osedition%] %winbuild% to [%targetedition%] 494 | echo: 495 | 496 | if %_dismapi%==1 ( 497 | call :dk_color %Green% "Notes-" 498 | echo: 499 | echo - Save your work before continue, system will auto restart. 500 | echo: 501 | echo - You will need to activate with HWID option once the edition is changed. 502 | %line% 503 | echo: 504 | choice /C:21 /N /M "[1] Continue [2] %_exitmsg% : " 505 | if !errorlevel!==1 exit /b 506 | ) 507 | 508 | ::======================================================================================================================================== 509 | 510 | if %_dismapi%==0 ( 511 | echo Installing %_chan% Key [%key%] 512 | echo: 513 | if %_wmic% EQU 1 wmic path SoftwareLicensingService where __CLASS='SoftwareLicensingService' call InstallProductKey ProductKey="%key%" %nul% 514 | if %_wmic% EQU 0 %psc% "(([WMISEARCHER]'SELECT Version FROM SoftwareLicensingService').Get()).InstallProductKey('%key%')" %nul% 515 | if not !errorlevel!==0 cscript //nologo %windir%\system32\slmgr.vbs /ipk %key% %nul% 516 | 517 | set error_code=!errorlevel! 518 | cmd /c exit /b !error_code! 519 | if !error_code! NEQ 0 set "error_code=[0x!=ExitCode!]" 520 | 521 | if !error_code! EQU 0 ( 522 | call :dk_refresh 523 | call :dk_color %Green% "[Successful]" 524 | echo: 525 | call :dk_color %Gray% "Reboot is required to properly change the Edition." 526 | ) else ( 527 | call :dk_color %Red% "[Unsuccessful] [Error Code: 0x!=ExitCode!]" 528 | echo Check this page for help. %mas%troubleshoot 529 | ) 530 | ) 531 | 532 | if %_dismapi%==1 ( 533 | echo: 534 | echo Applying the DISM API method with %_chan% Key %key%. Please wait... 535 | echo: 536 | %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':dismapi\:.*';& ([ScriptBlock]::Create($f[1])) %targetedition% %key%;" 537 | timeout /t 3 %nul1% 538 | echo: 539 | call :dk_color2 %Blue% "Check this page for help" %_Yellow% " %mas%change_edition_issues" 540 | ) 541 | %line% 542 | 543 | goto ced_done 544 | 545 | ::======================================================================================================================================== 546 | 547 | :cbsmethod 548 | 549 | cls 550 | mode con cols=105 lines=32 551 | %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;}" 552 | 553 | REM %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':checkrebootflag\:.*';iex ($f[1]);" | find /i "True" %nul% && ( 554 | REM %eline% 555 | REM echo Pending reboot flags found. 556 | REM echo: 557 | REM echo Restart the system and try again. 558 | REM goto ced_done 559 | REM ) 560 | 561 | echo: 562 | if defined dismnotworking call :dk_color %_Yellow% "Note - DISM.exe is not responding." 563 | echo Changing the Current Edition [%osedition%] %winbuild% to [%targetedition%] 564 | echo: 565 | call :dk_color %Blue% "Important - Save your work before continue, system will auto reboot." 566 | echo: 567 | choice /C:01 /N /M "[1] Continue [0] %_exitmsg% : " 568 | if %errorlevel%==1 exit /b 569 | 570 | echo: 571 | echo Initializing... 572 | echo: 573 | 574 | if %_stg%==0 (set stage=) else (set stage=-StageCurrent) 575 | %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -SetEdition %targetedition% %stage%;" 576 | echo: 577 | call :dk_color %Blue% "Incase of errors, you must restart your system before trying again." 578 | echo Check this page for help. %mas%troubleshoot 579 | %line% 580 | 581 | goto ced_done 582 | 583 | ::======================================================================================================================================== 584 | 585 | :ced_change_server 586 | 587 | cls 588 | mode con cols=105 lines=32 589 | %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;}" 590 | 591 | set key= 592 | set _chan= 593 | set "keyflow=Volume:GVLK Retail Volume:MAK OEM:NONSLP OEM:DM" 594 | 595 | call :ced_targetSKU %targetedition% 596 | if defined targetSKU call :ced_windowskey 597 | if defined key if defined pkeychannel set _chan=%pkeychannel% 598 | if not defined key call :changeeditiondata 599 | 600 | if not defined key ( 601 | %eline% 602 | echo [%targetedition% ^| %winbuild%] 603 | echo Unable to get product key from pkeyhelper.dll 604 | echo: 605 | echo Check this page for help. %mas%troubleshoot 606 | goto ced_done 607 | ) 608 | 609 | ::======================================================================================================================================== 610 | 611 | %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':checkrebootflag\:.*';iex ($f[1]);" | find /i "True" %nul% && ( 612 | %eline% 613 | echo Pending reboot flags found. 614 | echo: 615 | echo Restart the system and try again. 616 | goto ced_done 617 | ) 618 | 619 | cls 620 | echo: 621 | if defined dismnotworking call :dk_color %_Yellow% "Note - DISM.exe is not responding." 622 | echo Changing the Current Edition [%osedition%] %winbuild% to [%targetedition%] 623 | echo: 624 | echo Applying the command with %_chan% Key 625 | echo DISM /online /Set-Edition:%targetedition% /ProductKey:%key% /AcceptEula 626 | DISM /online /Set-Edition:%targetedition% /ProductKey:%key% /AcceptEula 627 | 628 | call :dk_color %Blue% "You must restart the system at this stage." 629 | echo Help: %mas%troubleshoot 630 | 631 | ::======================================================================================================================================== 632 | 633 | :ced_done 634 | 635 | echo: 636 | call :dk_color %_Yellow% "Press any key to %_exitmsg%..." 637 | pause %nul1% 638 | exit /b 639 | 640 | ::======================================================================================================================================== 641 | 642 | :: Check SKU value 643 | 644 | :dk_checksku 645 | 646 | set osSKU= 647 | set slcSKU= 648 | set wmiSKU= 649 | set regSKU= 650 | 651 | if %winbuild% GEQ 14393 (set info=Kernel-BrandingInfo) else (set info=Kernel-ProductInfo) 652 | set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 'Public, Static', 1, [int], @([String], [int].MakeByRefType()), 1, 3); 653 | set d1=%d1% $Sku = 0; [void]$TypeBuilder.CreateType()::SLGetWindowsInformationDWORD('%info%', [ref]$Sku); $Sku 654 | for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set slcSKU=%%s) 655 | if "%slcSKU%"=="0" set slcSKU= 656 | if 1%slcSKU% NEQ +1%slcSKU% set slcSKU= 657 | 658 | for /f "tokens=3 delims=." %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions" /v OSProductPfn %nul6%') do set "regSKU=%%a" 659 | if %_wmic% EQU 1 for /f "tokens=2 delims==" %%a in ('"wmic Path Win32_OperatingSystem Get OperatingSystemSKU /format:LIST" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" 660 | if %_wmic% EQU 0 for /f "tokens=1" %%a in ('%psc% "([WMI]'Win32_OperatingSystem=@').OperatingSystemSKU" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" 661 | 662 | set osSKU=%slcSKU% 663 | if not defined osSKU set osSKU=%wmiSKU% 664 | if not defined osSKU set osSKU=%regSKU% 665 | exit /b 666 | 667 | :: Refresh license status 668 | 669 | :dk_refresh 670 | 671 | if %_wmic% EQU 1 wmic path SoftwareLicensingService where __CLASS='SoftwareLicensingService' call RefreshLicenseStatus %nul% 672 | if %_wmic% EQU 0 %psc% "$null=(([WMICLASS]'SoftwareLicensingService').GetInstances()).RefreshLicenseStatus()" %nul% 673 | exit /b 674 | 675 | :: Get Windows Activation IDs 676 | 677 | :dk_actids 678 | 679 | set applist= 680 | if %_wmic% EQU 1 set "chkapp=for /f "tokens=2 delims==" %%a in ('"wmic path SoftwareLicensingProduct where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f') get ID /VALUE" %nul6%')" 681 | if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT ID FROM SoftwareLicensingProduct WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f''').Get()).ID ^| %% {echo ('ID='+$_)}" %nul6%')" 682 | %chkapp% do (if defined applist (call set "applist=!applist! %%a") else (call set "applist=%%a")) 683 | exit /b 684 | 685 | :: Get Edition list 686 | 687 | :ced_edilist 688 | 689 | if %_wmic% EQU 1 set "chkedi=for /f "tokens=2 delims==" %%a in ('"wmic path SoftwareLicensingProduct where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f') get LicenseFamily /VALUE" %nul6%')" 690 | if %_wmic% EQU 0 set "chkedi=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT LicenseFamily FROM SoftwareLicensingProduct WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f''').Get()).LicenseFamily ^| %% {echo ('LicenseFamily='+$_)}" %nul6%')" 691 | %chkedi% do ( 692 | call if exist %Systemdrive%\Windows\System32\spp\tokens\skus\%%a ( 693 | call set "_wtarget= !_wtarget! %%a " 694 | ) 695 | ) 696 | exit /b 697 | 698 | :: Check wmic.exe 699 | 700 | :dk_ckeckwmic 701 | 702 | set _wmic=0 703 | for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( 704 | wmic path Win32_ComputerSystem get CreationClassName /value %nul2% | find /i "computersystem" %nul1% && set _wmic=1 705 | ) 706 | exit /b 707 | 708 | :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) 709 | 710 | :dk_product 711 | 712 | call :dk_reflection 713 | 714 | set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3); 715 | set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') 716 | 717 | set winos= 718 | for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) 719 | echo "%winos%" | find /i "Windows" %nul1% || ( 720 | for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName %nul6%') do set "winos=%%b" 721 | if %winbuild% GEQ 22000 ( 722 | set winos=!winos:Windows 10=Windows 11! 723 | ) 724 | ) 725 | exit /b 726 | 727 | :: Common lines used in PowerShell reflection code 728 | 729 | :dk_reflection 730 | 731 | set ref=$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1); 732 | set ref=%ref% $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False); 733 | set ref=%ref% $TypeBuilder = $ModuleBuilder.DefineType(0); 734 | exit /b 735 | 736 | ::======================================================================================================================================== 737 | 738 | :: Check pending reboot flags 739 | 740 | :checkrebootflag: 741 | function Test-PendingReboot 742 | { 743 | if (Test-Path -Path "$env:windir\WinSxS\pending.xml") { return $true } 744 | if (Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -EA SilentlyContinue) { return $true } 745 | if (Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -EA SilentlyContinue) { return $true } 746 | try { 747 | $util = [wmiclass]"\\.\root\ccm\clientsdk:CCM_ClientUtilities" 748 | $status = $util.DetermineIfRebootPending() 749 | if(($status -ne $null) -and $status.RebootPending){ 750 | return $true 751 | } 752 | }catch{} 753 | 754 | return $false 755 | } 756 | Test-PendingReboot 757 | :checkrebootflag: 758 | 759 | ::======================================================================================================================================== 760 | 761 | :: Get Product Key from pkeyhelper.dll for future new editions 762 | :: It works on Windows 10 1803 (17134) and later builds. 763 | 764 | :dk_pkey 765 | 766 | call :dk_reflection 767 | 768 | set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('SkuGetProductKeyForEdition', 'pkeyhelper.dll', 'Public, Static', 1, [int], @([int], [String], [String].MakeByRefType(), [String].MakeByRefType()), 1, 3); 769 | set d1=%d1% $out = ''; [void]$TypeBuilder.CreateType()::SkuGetProductKeyForEdition(%1, %2, [ref]$out, [ref]$null); $out 770 | 771 | set pkey= 772 | for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkey=%%a) 773 | exit /b 774 | 775 | 776 | :: Get channel name for the key which was extracted from pkeyhelper.dll 777 | 778 | :dk_pkeychannel 779 | 780 | set k=%1 781 | set m=[Runtime.InteropServices.Marshal] 782 | set p=%SystemRoot%\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms 783 | 784 | set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('PidGenX', 'pidgenx.dll', 'Public, Static', 1, [int], @([String], [String], [String], [int], [IntPtr], [IntPtr], [IntPtr]), 1, 3); 785 | set d1=%d1% $r = [byte[]]::new(0x04F8); $r[0] = 0xF8; $r[1] = 0x04; $f = %m%::AllocHGlobal(0x04F8); %m%::Copy($r, 0, $f, 0x04F8); 786 | 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) 787 | 788 | set pkeychannel= 789 | for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkeychannel=%%a) 790 | exit /b 791 | 792 | :ced_windowskey 793 | 794 | for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b 795 | for %%# in (%keyflow%) do ( 796 | call :dk_pkey %targetSKU% '%%#' 797 | if defined pkey call :dk_pkeychannel !pkey! 798 | if /i [!pkeychannel!]==[%%#] ( 799 | set key=!pkey! 800 | exit /b 801 | ) 802 | ) 803 | exit /b 804 | 805 | ::======================================================================================================================================== 806 | 807 | :ced_targetSKU 808 | 809 | set k=%1 810 | set targetSKU= 811 | for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b 812 | 813 | call :dk_reflection 814 | 815 | set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('GetEditionIdFromName', 'pkeyhelper.dll', 'Public, Static', 1, [int], @([String], [int].MakeByRefType()), 1, 3); 816 | set d1=%d1% $out = 0; [void]$TypeBuilder.CreateType()::GetEditionIdFromName('%k%', [ref]$out); $out 817 | 818 | for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set targetSKU=%%a) 819 | if "%targetSKU%"=="0" set targetSKU= 820 | exit /b 821 | 822 | ::======================================================================================================================================== 823 | 824 | :dk_color 825 | 826 | if %_NCS% EQU 1 ( 827 | echo %esc%[%~1%~2%esc%[0m 828 | ) else ( 829 | %psc% write-host -back '%1' -fore '%2' '%3' 830 | ) 831 | exit /b 832 | 833 | :dk_color2 834 | 835 | if %_NCS% EQU 1 ( 836 | echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m 837 | ) else ( 838 | %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' 839 | ) 840 | exit /b 841 | 842 | ::======================================================================================================================================== 843 | 844 | :: https://github.com/Gamers-Against-Weed/Set-WindowsCbsEdition 845 | 846 | :cbsxml:[ 847 | param ( 848 | [Parameter()] 849 | [String]$SetEdition, 850 | 851 | [Parameter()] 852 | [Switch]$GetTargetEditions, 853 | 854 | [Parameter()] 855 | [Switch]$StageCurrent 856 | ) 857 | 858 | function Get-AssemblyIdentity { 859 | param ( 860 | [String]$PackageName 861 | ) 862 | 863 | $PackageName = [String]$PackageName 864 | $packageData = ($PackageName -split '~') 865 | 866 | if($packageData[3] -eq '') { 867 | $packageData[3] = 'neutral' 868 | } 869 | 870 | return "" 871 | } 872 | 873 | function Get-SxsName { 874 | param ( 875 | [String]$PackageName 876 | ) 877 | 878 | $name = ($PackageName -replace '[^A-z0-9\-\._]', '') 879 | 880 | if($name.Length -gt 40) { 881 | $name = ($name[0..18] -join '') + '\.\.' + ($name[-19..-1] -join '') 882 | } 883 | 884 | return $name.ToLower() 885 | } 886 | 887 | function Find-EditionXmlInSxs { 888 | param ( 889 | [String]$Edition 890 | ) 891 | 892 | $candidates = @($Edition, 'Client', 'Server') 893 | $winSxs = $Env:SystemRoot + '\WinSxS' 894 | $allInSxs = Get-ChildItem -Path $winSxs | select Name 895 | 896 | foreach($candidate in $candidates) { 897 | $name = Get-SxsName -PackageName "Microsoft-Windows-Editions-$candidate" 898 | $packages = $allInSxs | where name -Match ('^.*_'+$name+'_31bf3856ad364e35') 899 | 900 | if($packages.Length -eq 0) { 901 | continue 902 | } 903 | 904 | $package = $packages[-1].Name 905 | $testPath = $winSxs + "\$package\" + $Edition + 'Edition.xml' 906 | 907 | if(Test-Path -Path $testPath -PathType Leaf) { 908 | return $testPath 909 | } 910 | } 911 | 912 | return $null 913 | } 914 | 915 | function Find-EditionXml { 916 | param ( 917 | [String]$Edition 918 | ) 919 | 920 | $servicingEditions = $Env:SystemRoot + '\servicing\Editions' 921 | $editionXml = $Edition + 'Edition.xml' 922 | 923 | $editionXmlInServicing = $servicingEditions + '\' + $editionXml 924 | 925 | if(Test-Path -Path $editionXmlInServicing -PathType Leaf) { 926 | return $editionXmlInServicing 927 | } 928 | 929 | return Find-EditionXmlInSxs -Edition $Edition 930 | } 931 | 932 | function Write-UpgradeCandidates { 933 | param ( 934 | [HashTable]$InstallCandidates 935 | ) 936 | 937 | $editionCount = 0 938 | Write-Host 'Editions that can be upgraded to:' 939 | foreach($candidate in $InstallCandidates.Keys) { 940 | Write-Host "Target Edition : $candidate" 941 | $editionCount++ 942 | } 943 | 944 | if($editionCount -eq 0) { 945 | Write-Host '(no editions are available)' 946 | } 947 | } 948 | 949 | function Write-UpgradeXml { 950 | param ( 951 | [Array]$RemovalCandidates, 952 | [Array]$InstallCandidates, 953 | [Boolean]$Stage 954 | ) 955 | 956 | $removeAction = 'remove' 957 | if($Stage) { 958 | $removeAction = 'stage' 959 | } 960 | 961 | Write-Output '' 962 | Write-Output '' 963 | Write-Output '' 964 | 965 | foreach($package in $InstallCandidates) { 966 | Write-Output '' 967 | Write-Output (Get-AssemblyIdentity -PackageName $package) 968 | Write-Output '' 969 | } 970 | 971 | foreach($package in $RemovalCandidates) { 972 | Write-Output "" 973 | Write-Output (Get-AssemblyIdentity -PackageName $package) 974 | Write-Output '' 975 | } 976 | 977 | Write-Output '' 978 | Write-Output '' 979 | } 980 | 981 | function Write-Usage { 982 | Get-Help $script:MyInvocation.MyCommand.Path -detailed 983 | } 984 | 985 | $version = '1.0' 986 | $getTargetsParam = $GetTargetEditions.IsPresent 987 | $stageCurrentParam = $StageCurrent.IsPresent 988 | 989 | if($SetEdition -eq '' -and ($false -eq $getTargetsParam)) { 990 | Write-Usage 991 | Exit 1 992 | } 993 | 994 | $removalCandidates = @(); 995 | $installCandidates = @{}; 996 | 997 | $packages = Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages' | select Name | where { $_.name -match '^.*\\Microsoft-Windows-.*Edition~' } 998 | foreach($package in $packages) { 999 | $state = (Get-ItemProperty -Path "Registry::$($package.Name)").CurrentState 1000 | $packageName = ($package.Name -split '\\')[-1] 1001 | $packageEdition = (($packageName -split 'Edition~')[0] -split 'Microsoft-Windows-')[-1] 1002 | 1003 | if($state -eq 0x40) { 1004 | if($null -eq $installCandidates[$packageEdition]) { 1005 | $installCandidates[$packageEdition] = @() 1006 | } 1007 | 1008 | if($false -eq ($installCandidates[$packageEdition] -contains $packageName)) { 1009 | $installCandidates[$packageEdition] = $installCandidates[$packageEdition] + @($packageName) 1010 | } 1011 | } 1012 | 1013 | if((($state -eq 0x50) -or ($state -eq 0x70)) -and ($false -eq ($removalCandidates -contains $packageName))) { 1014 | $removalCandidates = $removalCandidates + @($packageName) 1015 | } 1016 | } 1017 | 1018 | if($getTargetsParam) { 1019 | Write-UpgradeCandidates -InstallCandidates $installCandidates 1020 | Exit 1021 | } 1022 | 1023 | if($false -eq ($installCandidates.Keys -contains $SetEdition)) { 1024 | Write-Error "The system cannot be upgraded to `"$SetEdition`"" 1025 | Exit 1 1026 | } 1027 | 1028 | $xmlPath = $Env:SystemRoot + '\Temp' + '\CbsUpgrade.xml' 1029 | 1030 | Write-UpgradeXml -RemovalCandidates $removalCandidates ` 1031 | -InstallCandidates $installCandidates[$SetEdition] ` 1032 | -Stage $stageCurrentParam >$xmlPath 1033 | 1034 | $editionXml = Find-EditionXml -Edition $SetEdition 1035 | if($null -eq $editionXml) { 1036 | Write-Warning 'Unable to find edition specific settings XML. Proceeding without it...' 1037 | } 1038 | 1039 | Write-Host 'Starting the upgrade process. This may take a while...' 1040 | 1041 | DISM.EXE /English /NoRestart /Online /Apply-Unattend:$xmlPath 1042 | $dismError = $LASTEXITCODE 1043 | 1044 | Remove-Item -Path $xmlPath -Force 1045 | 1046 | if(($dismError -ne 0) -and ($dismError -ne 3010)) { 1047 | Write-Error 'Failed to upgrade to the target edition' 1048 | Exit $dismError 1049 | } 1050 | 1051 | if($null -ne $editionXml) { 1052 | $destination = $Env:SystemRoot + '\' + $SetEdition + '.xml' 1053 | Copy-Item -Path $editionXml -Destination $destination 1054 | 1055 | DISM.EXE /English /NoRestart /Online /Apply-Unattend:$editionXml 1056 | $dismError = $LASTEXITCODE 1057 | 1058 | if(($dismError -ne 0) -and ($dismError -ne 3010)) { 1059 | Write-Error 'Failed to apply edition specific settings' 1060 | Exit $dismError 1061 | } 1062 | } 1063 | 1064 | Restart-Computer 1065 | :cbsxml:] 1066 | 1067 | ::======================================================================================================================================== 1068 | 1069 | :: Change edition using DISM API 1070 | :: Thanks to Alex (aka may, ave9858) 1071 | 1072 | :dismapi:[ 1073 | param ( 1074 | [Parameter()] 1075 | [String]$TargetEdition, 1076 | 1077 | [Parameter()] 1078 | [String]$Key 1079 | ) 1080 | 1081 | $AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1) 1082 | $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False) 1083 | $TB = $ModuleBuilder.DefineType(0) 1084 | 1085 | [void]$TB.DefinePInvokeMethod('DismInitialize', 'DismApi.dll', 22, 1, [int], @([int], [IntPtr], [IntPtr]), 1, 3) 1086 | [void]$TB.DefinePInvokeMethod('DismOpenSession', 'DismApi.dll', 22, 1, [int], @([String], [IntPtr], [IntPtr], [UInt32].MakeByRefType()), 1, 3) 1087 | [void]$TB.DefinePInvokeMethod('_DismSetEdition', 'DismApi.dll', 22, 1, [int], @([UInt32], [String], [String], [IntPtr], [IntPtr], [IntPtr]), 1, 3) 1088 | $Dism = $TB.CreateType() 1089 | 1090 | [void]$Dism::DismInitialize(2, 0, 0) 1091 | $Session = 0 1092 | [void]$Dism::DismOpenSession('DISM_{53BFAE52-B167-4E2F-A258-0A37B57FF845}', 0, 0, [ref]$Session) 1093 | if (!$Dism::_DismSetEdition($Session, "$TargetEdition", "$Key", 0, 0, 0)) { 1094 | Restart-Computer 1095 | } 1096 | :dismapi:] 1097 | 1098 | ::======================================================================================================================================== 1099 | 1100 | :: 1st column = Generic Retail/OEM/MAK/GVLK Key 1101 | :: 2nd column = Key Type 1102 | :: 3rd column = WMI Edition ID 1103 | :: 4th column = Version name incase same Edition ID is used in different OS versions with different key 1104 | :: Separator = _ 1105 | 1106 | :: For Windows 10/11 editions, HWID key is listed where ever possible, in Server versions, KMS key is listed where ever possible. 1107 | :: Only RS3 and older version Generic keys are stored here, later ones are extracted from the pkeyhelper.dll itself 1108 | 1109 | :changeeditiondata 1110 | 1111 | if %winbuild% GTR 17763 exit /b 1112 | if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*.mum" (set Cor=Cor) else (set Cor=) 1113 | 1114 | set h= 1115 | for %%# in ( 1116 | XGV%h%PP-NM%h%H47-7TT%h%HJ-W%h%3FW7-8HV%h%2C__OEM:NONSLP_Enterprise 1117 | D6R%h%D9-D4%h%N8T-RT9%h%QX-Y%h%W6YT-FCW%h%WJ______Retail_Starter 1118 | 3V6%h%Q6-NQ%h%XCX-V8Y%h%XR-9%h%QCYV-QPF%h%CT__Volume:MAK_EnterpriseN 1119 | 3NF%h%XW-2T%h%27M-2BD%h%W6-4%h%GHRV-68X%h%RX______Retail_StarterN 1120 | VK7%h%JG-NP%h%HTM-C97%h%JM-9%h%MPGT-3V6%h%6T______Retail_Professional 1121 | 2B8%h%7N-8K%h%FHP-DKV%h%6R-Y%h%2C8J-PKC%h%KT______Retail_ProfessionalN 1122 | 4CP%h%RK-NM%h%3K3-X6X%h%XQ-R%h%XX86-WXC%h%HW______Retail_CoreN 1123 | N24%h%34-X9%h%D7W-8PF%h%6X-8%h%DV9T-8TY%h%MD______Retail_CoreCountrySpecific 1124 | BT7%h%9Q-G7%h%N6G-PGB%h%YW-4%h%YWX6-6F4%h%BT______Retail_CoreSingleLanguage 1125 | YTM%h%G3-N6%h%DKC-DKB%h%77-7%h%M9GH-8HV%h%X7______Retail_Core 1126 | XKC%h%NC-J2%h%6Q9-KFH%h%D2-F%h%KTHY-KD7%h%2Y__OEM:NONSLP_PPIPro 1127 | YNM%h%GQ-8R%h%YV3-4PG%h%Q3-C%h%8XTP-7CF%h%BY______Retail_Education 1128 | 84N%h%GF-MH%h%BT6-FXB%h%X8-Q%h%WJK7-DRR%h%8H______Retail_EducationN 1129 | NK9%h%6Y-D9%h%CD8-W44%h%CQ-R%h%8YTK-DYJ%h%WX__OEM:NONSLP_EnterpriseS_RS1 1130 | FWN%h%7H-PF%h%93Q-4GG%h%P8-M%h%8RF3-MDW%h%WW__OEM:NONSLP_EnterpriseS_TH 1131 | 2DB%h%W3-N2%h%PJG-MVH%h%W3-G%h%7TDK-9HK%h%R4__Volume:MAK_EnterpriseSN_RS1 1132 | NTX%h%6B-BR%h%YC2-K67%h%86-F%h%6MVQ-M7V%h%2X__Volume:MAK_EnterpriseSN_TH 1133 | G3K%h%NM-CH%h%G6T-R36%h%X3-9%h%QDG6-8M8%h%K9______Retail_ProfessionalSingleLanguage 1134 | HNG%h%CC-Y3%h%8KG-QVK%h%8D-W%h%MWRK-X86%h%VK______Retail_ProfessionalCountrySpecific 1135 | DXG%h%7C-N3%h%6C4-C4H%h%TG-X%h%4T3X-2YV%h%77______Retail_ProfessionalWorkstation 1136 | WYP%h%NQ-8C%h%467-V2W%h%6J-T%h%X4WX-WT2%h%RQ______Retail_ProfessionalWorkstationN 1137 | 8PT%h%T6-RN%h%W4C-6V7%h%J2-C%h%2D3X-MHB%h%PB______Retail_ProfessionalEducation 1138 | GJT%h%YN-HD%h%MQY-FRR%h%76-H%h%VGC7-QPF%h%8P______Retail_ProfessionalEducationN 1139 | C4N%h%TJ-CX%h%6Q2-VXD%h%MR-X%h%VKGM-F9D%h%JC__Volume:MAK_EnterpriseG 1140 | 46P%h%N6-R9%h%BK9-CVH%h%KB-H%h%WQ9V-MBJ%h%Y8__Volume:MAK_EnterpriseGN 1141 | NJC%h%F7-PW%h%8QT-332%h%4D-6%h%88JX-2YV%h%66______Retail_ServerRdsh 1142 | V3W%h%VW-N2%h%PV2-CGW%h%C3-3%h%4QGF-VMJ%h%2C______Retail_Cloud 1143 | NH9%h%J3-68%h%WK7-6FB%h%93-4%h%K3DF-DJ4%h%F6______Retail_CloudN 1144 | 2HN%h%6V-HG%h%TM8-6C9%h%7C-R%h%K67V-JQP%h%FD______Retail_CloudE 1145 | WC2%h%BQ-8N%h%RM3-FDD%h%YY-2%h%BFGV-KHK%h%QY_Volume:GVLK_ServerStandard%Cor%_RS1 1146 | CB7%h%KF-BW%h%N84-R7R%h%2Y-7%h%93K2-8XD%h%DG_Volume:GVLK_ServerDatacenter%Cor%_RS1 1147 | JCK%h%RF-N3%h%7P4-C2D%h%82-9%h%YXRT-4M6%h%3B_Volume:GVLK_ServerSolution_RS1 1148 | QN4%h%C6-GB%h%JD2-FB4%h%22-G%h%HWJK-GJG%h%2R_Volume:GVLK_ServerCloudStorage_RS1 1149 | VP3%h%4G-4N%h%PPG-79J%h%TQ-8%h%64T4-R3M%h%QX_Volume:GVLK_ServerAzureCor_RS1 1150 | 9JQ%h%NQ-V8%h%HQ6-PKB%h%8H-G%h%GHRY-R62%h%H6______Retail_ServerAzureNano_RS1 1151 | VN8%h%D3-PR%h%82H-DB6%h%BJ-J%h%9P4M-92F%h%6J______Retail_ServerStorageStandard_RS1 1152 | 48T%h%QX-NV%h%K3R-D8Q%h%R3-G%h%THHM-8FH%h%XC______Retail_ServerStorageWorkgroup_RS1 1153 | 2HX%h%DN-KR%h%XHB-GPY%h%C7-Y%h%CKFJ-7FV%h%DG_Volume:GVLK_ServerDatacenterACor_RS3 1154 | PTX%h%N8-JF%h%HJM-4WC%h%78-M%h%PCBR-9W4%h%KR_Volume:GVLK_ServerStandardACor_RS3 1155 | ) do ( 1156 | for /f "tokens=1-4 delims=_" %%A in ("%%#") do if /i %targetedition%==%%C ( 1157 | 1158 | if not defined key ( 1159 | set 4th=%%D 1160 | if not defined 4th ( 1161 | set "key=%%A" & set "_chan=%%B" 1162 | ) else ( 1163 | echo "%branch%" | find /i "%%D" %nul1% && (set "key=%%A" & set "_chan=%%B") 1164 | ) 1165 | ) 1166 | ) 1167 | ) 1168 | exit /b 1169 | 1170 | ::======================================================================================================================================== 1171 | :: Leave empty line below 1172 | -------------------------------------------------------------------------------- /MAS/Separate-Files-Version/Check-Activation-Status-vbs.cmd: -------------------------------------------------------------------------------- 1 | @setlocal DisableDelayedExpansion 2 | @echo off 3 | @cls 4 | 5 | 6 | :: 7 | :: Check-Activation-Status 8 | :: Written by @abbodi1406 9 | :: forums.mydigitallife.net/posts/838808 10 | 11 | 12 | 13 | set _args= 14 | set _args=%* 15 | for %%A in (%_args%) do ( 16 | if /i "%%A"=="-wow" set _rel1=1 17 | if /i "%%A"=="-arm" set _rel2=1 18 | ) 19 | set "_cmdf=%~f0" 20 | if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 ( 21 | setlocal EnableDelayedExpansion 22 | start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow" 23 | exit /b 24 | ) 25 | if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 ( 26 | setlocal EnableDelayedExpansion 27 | start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm" 28 | exit /b 29 | ) 30 | color 07 31 | title Check Activation Status [vbs] 32 | set "SysPath=%SystemRoot%\System32" 33 | set "Path=%SystemRoot%\System32;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" 34 | if exist "%SystemRoot%\Sysnative\reg.exe" ( 35 | set "SysPath=%SystemRoot%\Sysnative" 36 | set "Path=%SystemRoot%\Sysnative;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%" 37 | ) 38 | 39 | :: Check LF line ending 40 | 41 | pushd "%~dp0" 42 | >nul findstr /v "$" "%~nx0" && ( 43 | echo: 44 | echo Error: Script either has LF line ending issue or an empty line at the end of the script is missing. 45 | echo: 46 | ping 127.0.0.1 -n 6 >nul 47 | popd 48 | exit /b 49 | ) 50 | popd 51 | 52 | set ohook= 53 | for %%# in (15 16) do ( 54 | for %%A in ("%ProgramFiles%" "%ProgramW6432%" "%ProgramFiles(x86)%") do ( 55 | if exist "%%~A\Microsoft Office\Office%%#\sppc*dll" set ohook=1 56 | ) 57 | ) 58 | 59 | for %%# in (System SystemX86) do ( 60 | for %%G in ("Office 15" "Office") do ( 61 | for %%A in ("%ProgramFiles%" "%ProgramW6432%" "%ProgramFiles(x86)%") do ( 62 | if exist "%%~A\Microsoft %%~G\root\vfs\%%#\sppc*dll" set ohook=1 63 | ) 64 | ) 65 | ) 66 | 67 | set "_bit=64" 68 | set "_wow=1" 69 | if /i "%PROCESSOR_ARCHITECTURE%"=="x86" if "%PROCESSOR_ARCHITEW6432%"=="" set "_wow=0"&set "_bit=32" 70 | set "_utemp=%TEMP%" 71 | set "line2=************************************************************" 72 | set "line3=____________________________________________________________" 73 | set _sO16vbs=0 74 | set _sO15vbs=0 75 | if exist "%ProgramFiles%\Microsoft Office\Office15\ospp.vbs" ( 76 | set _sO15vbs=1 77 | ) else if exist "%ProgramW6432%\Microsoft Office\Office15\ospp.vbs" ( 78 | set _sO15vbs=1 79 | ) else if exist "%ProgramFiles(x86)%\Microsoft Office\Office15\ospp.vbs" ( 80 | set _sO15vbs=1 81 | ) 82 | setlocal EnableDelayedExpansion 83 | echo %line2% 84 | echo *** Windows Status *** 85 | echo %line2% 86 | pushd "!_utemp!" 87 | copy /y %SystemRoot%\System32\slmgr.vbs . >nul 2>&1 88 | net start sppsvc /y >nul 2>&1 89 | cscript //nologo slmgr.vbs /dli || (echo Error executing slmgr.vbs&del /f /q slmgr.vbs&popd&goto :casVend) 90 | cscript //nologo slmgr.vbs /xpr 91 | del /f /q slmgr.vbs >nul 2>&1 92 | popd 93 | echo %line3% 94 | 95 | if defined ohook ( 96 | echo. 97 | echo. 98 | echo %line2% 99 | echo *** Office Ohook Activation Status *** 100 | echo %line2% 101 | echo. 102 | powershell "write-host -back 'Black' -fore 'Yellow' 'Ohook for permanent Office activation is installed.'; write-host -back 'Black' -fore 'Yellow' 'You can ignore below Office activation status.'" 103 | echo. 104 | ) 105 | 106 | :casVo16 107 | set office= 108 | for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\16.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b") 109 | if exist "!office!\ospp.vbs" ( 110 | set _sO16vbs=1 111 | echo. 112 | echo %line2% 113 | if %_sO15vbs% EQU 0 ( 114 | echo *** Office 2016 %_bit%-bit Status *** 115 | ) else ( 116 | echo *** Office 2013/2016 Status *** 117 | ) 118 | echo %line2% 119 | cscript //nologo "!office!\ospp.vbs" /dstatus 120 | ) 121 | if %_wow%==0 goto :casVo13 122 | set office= 123 | for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\16.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b") 124 | if exist "!office!\ospp.vbs" ( 125 | set _sO16vbs=1 126 | echo. 127 | echo %line2% 128 | if %_sO15vbs% EQU 0 ( 129 | echo *** Office 2016 32-bit Status *** 130 | ) else ( 131 | echo *** Office 2013/2016 Status *** 132 | ) 133 | echo %line2% 134 | cscript //nologo "!office!\ospp.vbs" /dstatus 135 | ) 136 | 137 | :casVo13 138 | if %_sO16vbs% EQU 1 goto :casVo10 139 | set office= 140 | for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b") 141 | if exist "!office!\ospp.vbs" ( 142 | echo. 143 | echo %line2% 144 | echo *** Office 2013 %_bit%-bit Status *** 145 | echo %line2% 146 | cscript //nologo "!office!\ospp.vbs" /dstatus 147 | ) 148 | if %_wow%==0 goto :casVo10 149 | set office= 150 | for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b") 151 | if exist "!office!\ospp.vbs" ( 152 | echo. 153 | echo %line2% 154 | echo *** Office 2013 32-bit Status *** 155 | echo %line2% 156 | cscript //nologo "!office!\ospp.vbs" /dstatus 157 | ) 158 | 159 | :casVo10 160 | set office= 161 | for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b") 162 | if exist "!office!\ospp.vbs" ( 163 | echo. 164 | echo %line2% 165 | echo *** Office 2010 %_bit%-bit Status *** 166 | echo %line2% 167 | cscript //nologo "!office!\ospp.vbs" /dstatus 168 | ) 169 | if %_wow%==0 goto :casVc16 170 | set office= 171 | for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot /v Path" 2^>nul') do (set "office=%%b") 172 | if exist "!office!\ospp.vbs" ( 173 | echo. 174 | echo %line2% 175 | echo *** Office 2010 32-bit Status *** 176 | echo %line2% 177 | cscript //nologo "!office!\ospp.vbs" /dstatus 178 | ) 179 | 180 | :casVc16 181 | reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath >nul 2>&1 || ( 182 | reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun /v InstallPath >nul 2>&1 || goto :casVc13 183 | ) 184 | set office= 185 | for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath" 2^>nul') do (set "office=%%b\Office16") 186 | if exist "!office!\ospp.vbs" ( 187 | set _sO16vbs=1 188 | echo. 189 | echo %line2% 190 | if %_sO15vbs% EQU 0 ( 191 | echo *** Office 2016-2021 C2R Status *** 192 | ) else ( 193 | echo *** Office 2013-2021 Status *** 194 | ) 195 | echo %line2% 196 | cscript //nologo "!office!\ospp.vbs" /dstatus 197 | ) 198 | if %_wow%==0 goto :casVc13 199 | set office= 200 | for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\ClickToRun /v InstallPath" 2^>nul') do (set "office=%%b\Office16") 201 | if exist "!office!\ospp.vbs" ( 202 | set _sO16vbs=1 203 | echo. 204 | echo %line2% 205 | if %_sO15vbs% EQU 0 ( 206 | echo *** Office 2016-2021 C2R Status *** 207 | ) else ( 208 | echo *** Office 2013-2021 Status *** 209 | ) 210 | echo %line2% 211 | cscript //nologo "!office!\ospp.vbs" /dstatus 212 | ) 213 | 214 | :casVc13 215 | if %_sO16vbs% EQU 1 goto :casVc10 216 | reg query HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun /v InstallPath >nul 2>&1 || ( 217 | reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\ClickToRun /v InstallPath >nul 2>&1 || goto :casVc10 218 | ) 219 | set office= 220 | if exist "%ProgramFiles%\Microsoft Office\Office15\ospp.vbs" ( 221 | set "office=%ProgramFiles%\Microsoft Office\Office15" 222 | ) else if exist "%ProgramW6432%\Microsoft Office\Office15\ospp.vbs" ( 223 | set "office=%ProgramW6432%\Microsoft Office\Office15" 224 | ) else if exist "%ProgramFiles(x86)%\Microsoft Office\Office15\ospp.vbs" ( 225 | set "office=%ProgramFiles(x86)%\Microsoft Office\Office15" 226 | ) 227 | if exist "!office!\ospp.vbs" ( 228 | echo. 229 | echo %line2% 230 | echo *** Office 2013 C2R Status *** 231 | echo %line2% 232 | cscript //nologo "!office!\ospp.vbs" /dstatus 233 | ) 234 | 235 | :casVc10 236 | if %_wow%==0 reg query HKLM\SOFTWARE\Microsoft\Office\14.0\CVH /f Click2run /k >nul 2>&1 || goto :casVend 237 | if %_wow%==1 reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\CVH /f Click2run /k >nul 2>&1 || goto :casVend 238 | set office= 239 | if exist "%ProgramFiles%\Microsoft Office\Office14\ospp.vbs" ( 240 | set "office=%ProgramFiles%\Microsoft Office\Office14" 241 | ) else if exist "%ProgramW6432%\Microsoft Office\Office14\ospp.vbs" ( 242 | set "office=%ProgramW6432%\Microsoft Office\Office14" 243 | ) else if exist "%ProgramFiles(x86)%\Microsoft Office\Office14\ospp.vbs" ( 244 | set "office=%ProgramFiles(x86)%\Microsoft Office\Office14" 245 | ) 246 | if exist "!office!\ospp.vbs" ( 247 | echo. 248 | echo %line2% 249 | echo *** Office 2010 C2R Status *** 250 | echo %line2% 251 | cscript //nologo "!office!\ospp.vbs" /dstatus 252 | ) 253 | 254 | :casVend 255 | echo. 256 | echo Press any key to exit. 257 | pause >nul 258 | exit /b 259 | :: Leave empty line below 260 | -------------------------------------------------------------------------------- /MAS/Separate-Files-Version/Check-Activation-Status-wmi.cmd: -------------------------------------------------------------------------------- 1 | @setlocal DisableDelayedExpansion 2 | @echo off 3 | 4 | 5 | 6 | :: Check-Activation-Status 7 | :: Written by @abbodi1406 8 | :: forums.mydigitallife.net/posts/838808 9 | 10 | 11 | 12 | 13 | set WMI_VBS=0 14 | @cls 15 | set _args= 16 | set _args=%* 17 | for %%A in (%_args%) do ( 18 | if /i "%%A"=="-wow" set _rel1=1 19 | if /i "%%A"=="-arm" set _rel2=1 20 | ) 21 | set "_cmdf=%~f0" 22 | if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 ( 23 | setlocal EnableDelayedExpansion 24 | start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow" 25 | exit /b 26 | ) 27 | if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 ( 28 | setlocal EnableDelayedExpansion 29 | start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm" 30 | exit /b 31 | ) 32 | color 07 33 | title Check Activation Status [wmi] 34 | set wspp=SoftwareLicensingProduct 35 | set wsps=SoftwareLicensingService 36 | set ospp=OfficeSoftwareProtectionProduct 37 | set osps=OfficeSoftwareProtectionService 38 | set winApp=55c92734-d682-4d71-983e-d6ec3f16059f 39 | set o14App=59a52881-a989-479d-af46-f275c6370663 40 | set o15App=0ff1ce15-a989-479d-af46-f275c6370663 41 | for %%# in (spp_get,ospp_get,cW1nd0ws,sppw,c0ff1ce15,sppo,osppsvc,ospp14,ospp15) do set "%%#=" 42 | for /f "tokens=6 delims=[]. " %%# in ('ver') do set winbuild=%%# 43 | set "spp_get=Description, DiscoveredKeyManagementServiceMachineName, DiscoveredKeyManagementServiceMachinePort, EvaluationEndDate, GracePeriodRemaining, ID, KeyManagementServiceMachine, KeyManagementServicePort, KeyManagementServiceProductKeyID, LicenseStatus, LicenseStatusReason, Name, PartialProductKey, ProductKeyID, VLActivationInterval, VLRenewalInterval" 44 | set "ospp_get=%spp_get%" 45 | if %winbuild% GEQ 9200 set "spp_get=%spp_get%, KeyManagementServiceLookupDomain, VLActivationTypeEnabled" 46 | if %winbuild% GEQ 9600 set "spp_get=%spp_get%, DiscoveredKeyManagementServiceMachineIpAddress, ProductKeyChannel" 47 | set "_work=%~dp0" 48 | set "_batf=%~f0" 49 | set "_batp=%_batf:'=''%" 50 | set "_Local=%LocalAppData%" 51 | set _Identity=0 52 | setlocal EnableDelayedExpansion 53 | dir /b /s /a:-d "!_Local!\Microsoft\Office\Licenses\*1*" 1>nul 2>nul && set _Identity=1 54 | dir /b /s /a:-d "!ProgramData!\Microsoft\Office\Licenses\*1*" 1>nul 2>nul && set _Identity=1 55 | pushd "!_work!" 56 | setlocal DisableDelayedExpansion 57 | if %winbuild% LSS 9200 if not exist "%SystemRoot%\servicing\Packages\Microsoft-Windows-PowerShell-WTR-Package~*.mum" set _Identity=0 58 | 59 | set "SysPath=%SystemRoot%\System32" 60 | set "Path=%SystemRoot%\System32;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" 61 | if exist "%SystemRoot%\Sysnative\reg.exe" ( 62 | set "SysPath=%SystemRoot%\Sysnative" 63 | set "Path=%SystemRoot%\Sysnative;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%" 64 | ) 65 | 66 | :: Check LF line ending 67 | 68 | pushd "%~dp0" 69 | >nul findstr /v "$" "%~nx0" && ( 70 | echo: 71 | echo Error: Script either has LF line ending issue or an empty line at the end of the script is missing. 72 | echo: 73 | ping 127.0.0.1 -n 6 >nul 74 | popd 75 | exit /b 76 | ) 77 | popd 78 | 79 | set ohook= 80 | for %%# in (15 16) do ( 81 | for %%A in ("%ProgramFiles%" "%ProgramW6432%" "%ProgramFiles(x86)%") do ( 82 | if exist "%%~A\Microsoft Office\Office%%#\sppc*dll" set ohook=1 83 | ) 84 | ) 85 | 86 | for %%# in (System SystemX86) do ( 87 | for %%G in ("Office 15" "Office") do ( 88 | for %%A in ("%ProgramFiles%" "%ProgramW6432%" "%ProgramFiles(x86)%") do ( 89 | if exist "%%~A\Microsoft %%~G\root\vfs\%%#\sppc*dll" set ohook=1 90 | ) 91 | ) 92 | ) 93 | 94 | set _cwmi=0 95 | for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( 96 | wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "ComputerSystem" 1>nul && set _cwmi=1 97 | ) 98 | 99 | if %_cwmi% EQU 0 ( 100 | echo: 101 | echo Error: WMI is not responding in the system. 102 | echo: 103 | echo In MAS, Goto Troubleshoot and run Fix WMI option. 104 | echo: 105 | echo Press any key to exit... 106 | pause >nul 107 | exit /b 108 | ) 109 | 110 | set "line2=************************************************************" 111 | set "line3=____________________________________________________________" 112 | set "_psc=powershell" 113 | 114 | set _prsh=1 115 | for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" set _prsh=0 116 | set "_csg=cscript.exe //NoLogo //Job:WmiMulti "%~nx0?.wsf"" 117 | set "_csq=cscript.exe //NoLogo //Job:WmiQuery "%~nx0?.wsf"" 118 | set "_csx=cscript.exe //NoLogo //Job:XPDT "%~nx0?.wsf"" 119 | if %_cwmi% EQU 0 set WMI_VBS=1 120 | if %WMI_VBS% EQU 0 ( 121 | set "_zz1=wmic path" 122 | set "_zz2=where" 123 | set "_zz3=get" 124 | set "_zz4=/value" 125 | set "_zz5=(" 126 | set "_zz6=)" 127 | set "_zz7="wmic path" 128 | set "_zz8=/value"" 129 | ) else ( 130 | set "_zz1=%_csq%" 131 | set "_zz2=" 132 | set "_zz3=" 133 | set "_zz4=" 134 | set "_zz5="" 135 | set "_zz6="" 136 | set "_zz7=%_csq%" 137 | set "_zz8=" 138 | ) 139 | set _WSH=0 140 | set OsppHook=1 141 | sc query osppsvc >nul 2>&1 142 | if %errorlevel% EQU 1060 set OsppHook=0 143 | 144 | net start sppsvc /y >nul 2>&1 145 | call :casWpkey %wspp% %winApp% cW1nd0ws sppw 146 | if %winbuild% GEQ 9200 call :casWpkey %wspp% %o15App% c0ff1ce15 sppo 147 | if %OsppHook% NEQ 0 ( 148 | net start osppsvc /y >nul 2>&1 149 | call :casWpkey %ospp% %o14App% osppsvc ospp14 150 | if %winbuild% LSS 9200 call :casWpkey %ospp% %o15App% osppsvc ospp15 151 | ) 152 | 153 | echo %line2% 154 | echo *** Windows Status *** 155 | echo %line2% 156 | if not defined cW1nd0ws ( 157 | echo. 158 | echo Error: product key not found. 159 | goto :casWcon 160 | ) 161 | set winID=1 162 | set "_qr=%_zz7% %wspp% %_zz2% %_zz5%ApplicationID='%winApp%' and PartialProductKey is not null%_zz6% %_zz3% ID %_zz8%" 163 | for /f "tokens=2 delims==" %%# in ('%_qr%') do ( 164 | set "chkID=%%#" 165 | call :casWdet "%wspp%" "%wsps%" "%spp_get%" 166 | call :casWout 167 | echo %line3% 168 | echo. 169 | ) 170 | 171 | if defined ohook ( 172 | echo. 173 | echo. 174 | echo %line2% 175 | echo *** Office Ohook Activation Status *** 176 | echo %line2% 177 | echo. 178 | powershell "write-host -back 'Black' -fore 'Yellow' 'Ohook for permanent Office activation is installed.'; write-host -back 'Black' -fore 'Yellow' 'You can ignore below Office activation status.'" 179 | echo. 180 | ) 181 | 182 | :casWcon 183 | set winID=0 184 | set verbose=1 185 | if not defined c0ff1ce15 ( 186 | if defined osppsvc goto :casWospp 187 | goto :casWend 188 | ) 189 | echo %line2% 190 | echo *** Office Status *** 191 | echo %line2% 192 | set "_qr=%_zz7% %wspp% %_zz2% %_zz5%ApplicationID='%o15App%' and PartialProductKey is not null%_zz6% %_zz3% ID %_zz8%" 193 | for /f "tokens=2 delims==" %%# in ('%_qr%') do ( 194 | set "chkID=%%#" 195 | call :casWdet "%wspp%" "%wsps%" "%spp_get%" 196 | call :casWout 197 | echo %line3% 198 | echo. 199 | ) 200 | set verbose=0 201 | if defined osppsvc goto :casWospp 202 | goto :casWend 203 | 204 | :casWospp 205 | if %verbose% EQU 1 ( 206 | echo %line2% 207 | echo *** Office Status *** 208 | echo %line2% 209 | ) 210 | set "_qr=%_zz7% %ospp% %_zz2% %_zz5%ApplicationID='%o15App%' and PartialProductKey is not null%_zz6% %_zz3% ID %_zz8%" 211 | if defined ospp15 for /f "tokens=2 delims==" %%# in ('%_qr%') do ( 212 | set "chkID=%%#" 213 | call :casWdet "%ospp%" "%osps%" "%ospp_get%" 214 | call :casWout 215 | echo %line3% 216 | echo. 217 | ) 218 | set "_qr=%_zz7% %ospp% %_zz2% %_zz5%ApplicationID='%o14App%' and PartialProductKey is not null%_zz6% %_zz3% ID %_zz8%" 219 | if defined ospp14 for /f "tokens=2 delims==" %%# in ('%_qr%') do ( 220 | set "chkID=%%#" 221 | call :casWdet "%ospp%" "%osps%" "%ospp_get%" 222 | call :casWout 223 | echo %line3% 224 | echo. 225 | ) 226 | goto :casWend 227 | 228 | :casWpkey 229 | set "_qr=%_zz1% %1 %_zz2% %_zz5%ApplicationID='%2' and PartialProductKey is not null%_zz6% %_zz3% ID %_zz4%" 230 | %_qr% 2>nul | findstr /i ID 1>nul && (set %3=1&set %4=1) 231 | exit /b 232 | 233 | :casWdet 234 | for %%# in (%~3) do set "%%#=" 235 | if /i %~1==%ospp% for %%# in (DiscoveredKeyManagementServiceMachineIpAddress, KeyManagementServiceLookupDomain, ProductKeyChannel, VLActivationTypeEnabled) do set "%%#=" 236 | set "cKmsClient=" 237 | set "cTblClient=" 238 | set "cAvmClient=" 239 | set "ExpireMsg=" 240 | set "_xpr=" 241 | set "_qr="wmic path %~1 where ID='%chkID%' get %~3 /value" ^| findstr ^=" 242 | if %WMI_VBS% NEQ 0 set "_qr=%_csg% %~1 "ID='%chkID%'" "%~3"" 243 | for /f "tokens=* delims=" %%# in ('%_qr%') do set "%%#" 244 | 245 | set /a _gpr=(GracePeriodRemaining+1440-1)/1440 246 | echo %Description%| findstr /i VOLUME_KMSCLIENT 1>nul && (set cKmsClient=1&set _mTag=Volume) 247 | echo %Description%| findstr /i TIMEBASED_ 1>nul && (set cTblClient=1&set _mTag=Timebased) 248 | echo %Description%| findstr /i VIRTUAL_MACHINE_ACTIVATION 1>nul && (set cAvmClient=1&set _mTag=Automatic VM) 249 | cmd /c exit /b %LicenseStatusReason% 250 | set "LicenseReason=%=ExitCode%" 251 | set "LicenseMsg=Time remaining: %GracePeriodRemaining% minute(s) (%_gpr% day(s))" 252 | if %_gpr% GEQ 1 if %_WSH% EQU 1 ( 253 | for /f "tokens=* delims=" %%# in ('%_csx% %GracePeriodRemaining%') do set "_xpr=%%#" 254 | ) 255 | if %_gpr% GEQ 1 if %_prsh% EQU 1 if not defined _xpr ( 256 | for /f "tokens=* delims=" %%# in ('%_psc% "$([DateTime]::Now.addMinutes(%GracePeriodRemaining%)).ToString('yyyy-MM-dd HH:mm:ss')" 2^>nul') do set "_xpr=%%#" 257 | title Check Activation Status [wmi] 258 | ) 259 | 260 | if %LicenseStatus% EQU 0 ( 261 | set "License=Unlicensed" 262 | set "LicenseMsg=" 263 | ) 264 | if %LicenseStatus% EQU 1 ( 265 | set "License=Licensed" 266 | set "LicenseMsg=" 267 | if %GracePeriodRemaining% EQU 0 ( 268 | if %winID% EQU 1 (set "ExpireMsg=The machine is permanently activated.") else (set "ExpireMsg=The product is permanently activated.") 269 | ) else ( 270 | set "LicenseMsg=%_mTag% activation expiration: %GracePeriodRemaining% minute(s) (%_gpr% day(s))" 271 | if defined _xpr set "ExpireMsg=%_mTag% activation will expire %_xpr%" 272 | ) 273 | ) 274 | if %LicenseStatus% EQU 2 ( 275 | set "License=Initial grace period" 276 | if defined _xpr set "ExpireMsg=Initial grace period ends %_xpr%" 277 | ) 278 | if %LicenseStatus% EQU 3 ( 279 | set "License=Additional grace period (KMS license expired or hardware out of tolerance)" 280 | if defined _xpr set "ExpireMsg=Additional grace period ends %_xpr%" 281 | ) 282 | if %LicenseStatus% EQU 4 ( 283 | set "License=Non-genuine grace period." 284 | if defined _xpr set "ExpireMsg=Non-genuine grace period ends %_xpr%" 285 | ) 286 | if %LicenseStatus% EQU 6 ( 287 | set "License=Extended grace period" 288 | if defined _xpr set "ExpireMsg=Extended grace period ends %_xpr%" 289 | ) 290 | if %LicenseStatus% EQU 5 ( 291 | set "License=Notification" 292 | if "%LicenseReason%"=="C004F200" (set "LicenseMsg=Notification Reason: 0xC004F200 (non-genuine)." 293 | ) else if "%LicenseReason%"=="C004F009" (set "LicenseMsg=Notification Reason: 0xC004F009 (grace time expired)." 294 | ) else (set "LicenseMsg=Notification Reason: 0x%LicenseReason%" 295 | ) 296 | ) 297 | if %LicenseStatus% GTR 6 ( 298 | set "License=Unknown" 299 | set "LicenseMsg=" 300 | ) 301 | if not defined cKmsClient exit /b 302 | 303 | if %KeyManagementServicePort%==0 set KeyManagementServicePort=1688 304 | set "KmsReg=Registered KMS machine name: %KeyManagementServiceMachine%:%KeyManagementServicePort%" 305 | if "%KeyManagementServiceMachine%"=="" set "KmsReg=Registered KMS machine name: KMS name not available" 306 | 307 | if %DiscoveredKeyManagementServiceMachinePort%==0 set DiscoveredKeyManagementServiceMachinePort=1688 308 | set "KmsDns=KMS machine name from DNS: %DiscoveredKeyManagementServiceMachineName%:%DiscoveredKeyManagementServiceMachinePort%" 309 | if "%DiscoveredKeyManagementServiceMachineName%"=="" set "KmsDns=DNS auto-discovery: KMS name not available" 310 | 311 | set "_qr="wmic path %~2 get ClientMachineID, KeyManagementServiceHostCaching /value" ^| findstr ^=" 312 | if %WMI_VBS% NEQ 0 set "_qr=%_csg% %~2 "ClientMachineID, KeyManagementServiceHostCaching"" 313 | for /f "tokens=* delims=" %%# in ('%_qr%') do set "%%#" 314 | if /i %KeyManagementServiceHostCaching%==True (set KeyManagementServiceHostCaching=Enabled) else (set KeyManagementServiceHostCaching=Disabled) 315 | 316 | if %winbuild% LSS 9200 exit /b 317 | if /i %~1==%ospp% exit /b 318 | 319 | if "%KeyManagementServiceLookupDomain%"=="" set "KeyManagementServiceLookupDomain=" 320 | 321 | if %VLActivationTypeEnabled% EQU 3 ( 322 | set VLActivationType=Token 323 | ) else if %VLActivationTypeEnabled% EQU 2 ( 324 | set VLActivationType=KMS 325 | ) else if %VLActivationTypeEnabled% EQU 1 ( 326 | set VLActivationType=AD 327 | ) else ( 328 | set VLActivationType=All 329 | ) 330 | 331 | if %winbuild% LSS 9600 exit /b 332 | if "%DiscoveredKeyManagementServiceMachineIpAddress%"=="" set "DiscoveredKeyManagementServiceMachineIpAddress=not available" 333 | exit /b 334 | 335 | :casWout 336 | echo. 337 | echo Name: %Name% 338 | echo Description: %Description% 339 | echo Activation ID: %ID% 340 | echo Extended PID: %ProductKeyID% 341 | if defined ProductKeyChannel echo Product Key Channel: %ProductKeyChannel% 342 | echo Partial Product Key: %PartialProductKey% 343 | echo License Status: %License% 344 | if defined LicenseMsg echo %LicenseMsg% 345 | if not %LicenseStatus%==0 if not %EvaluationEndDate:~0,8%==16010101 echo Evaluation End Date: %EvaluationEndDate:~0,4%-%EvaluationEndDate:~4,2%-%EvaluationEndDate:~6,2% %EvaluationEndDate:~8,2%:%EvaluationEndDate:~10,2% UTC 346 | if not defined cKmsClient ( 347 | if defined ExpireMsg echo.&echo. %ExpireMsg% 348 | exit /b 349 | ) 350 | if defined VLActivationTypeEnabled echo Configured Activation Type: %VLActivationType% 351 | echo. 352 | if not %LicenseStatus%==1 ( 353 | echo Please activate the product in order to update KMS client information values. 354 | exit /b 355 | ) 356 | echo Most recent activation information: 357 | echo Key Management Service client information 358 | echo. Client Machine ID (CMID): %ClientMachineID% 359 | echo. %KmsDns% 360 | echo. %KmsReg% 361 | if defined DiscoveredKeyManagementServiceMachineIpAddress echo. KMS machine IP address: %DiscoveredKeyManagementServiceMachineIpAddress% 362 | echo. KMS machine extended PID: %KeyManagementServiceProductKeyID% 363 | echo. Activation interval: %VLActivationInterval% minutes 364 | echo. Renewal interval: %VLRenewalInterval% minutes 365 | echo. K.M.S host caching: %KeyManagementServiceHostCaching% 366 | if defined KeyManagementServiceLookupDomain echo. KMS SRV record lookup domain: %KeyManagementServiceLookupDomain% 367 | if defined ExpireMsg echo.&echo. %ExpireMsg% 368 | exit /b 369 | 370 | :casWend 371 | if %_Identity% EQU 1 if %_prsh% EQU 1 ( 372 | echo %line2% 373 | echo *** Office vNext Status *** 374 | echo %line2% 375 | setlocal EnableDelayedExpansion 376 | %_psc% "$f=[IO.File]::ReadAllText('!_batp!') -split ':vNextDiag\:.*';iex ($f[1])" 377 | title Check Activation Status [wmi] 378 | echo %line3% 379 | echo. 380 | ) 381 | echo. 382 | echo Press any key to exit. 383 | pause >nul 384 | exit /b 385 | 386 | :vNextDiag: 387 | function PrintModePerPridFromRegistry 388 | { 389 | $vNextRegkey = "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext" 390 | $vNextPrids = Get-Item -Path $vNextRegkey -ErrorAction Ignore | Select-Object -ExpandProperty 'property' | Where-Object -FilterScript {$_.ToLower() -like "*retail" -or $_.ToLower() -like "*volume"} 391 | If ($vNextPrids -Eq $null) 392 | { 393 | Write-Host "No registry keys found." 394 | Return 395 | } 396 | $vNextPrids | ForEach ` 397 | { 398 | $mode = (Get-ItemProperty -Path $vNextRegkey -Name $_).$_ 399 | Switch ($mode) 400 | { 401 | 2 { $mode = "vNext"; Break } 402 | 3 { $mode = "Device"; Break } 403 | Default { $mode = "Legacy"; Break } 404 | } 405 | Write-Host $_ = $mode 406 | } 407 | } 408 | function PrintSharedComputerLicensing 409 | { 410 | $scaRegKey = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration" 411 | $scaValue = Get-ItemProperty -Path $scaRegKey -ErrorAction Ignore | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction Ignore 412 | $scaRegKey2 = "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing" 413 | $scaValue2 = Get-ItemProperty -Path $scaRegKey2 -ErrorAction Ignore | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction Ignore 414 | $scaPolicyKey = "HKLM:\SOFTWARE\Policies\Microsoft\Office\16.0\Common\Licensing" 415 | $scaPolicyValue = Get-ItemProperty -Path $scaPolicyKey -ErrorAction Ignore | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction Ignore 416 | If ($scaValue -Eq $null -And $scaValue2 -Eq $null -And $scaPolicyValue -Eq $null) 417 | { 418 | Write-Host "No registry keys found." 419 | Return 420 | } 421 | $scaModeValue = $scaValue -Or $scaValue2 -Or $scaPolicyValue 422 | If ($scaModeValue -Eq 0) 423 | { 424 | $scaMode = "Disabled" 425 | } 426 | If ($scaModeValue -Eq 1) 427 | { 428 | $scaMode = "Enabled" 429 | } 430 | Write-Host "SharedComputerLicensing" = $scaMode 431 | Write-Host 432 | $tokenFiles = $null 433 | $tokenPath = "${env:LOCALAPPDATA}\Microsoft\Office\16.0\Licensing" 434 | If (Test-Path $tokenPath) 435 | { 436 | $tokenFiles = Get-ChildItem -Path $tokenPath -Recurse -File -Filter "*authString*" 437 | } 438 | If ($tokenFiles.length -Eq 0) 439 | { 440 | Write-Host "No tokens found." 441 | Return 442 | } 443 | $tokenFiles | ForEach ` 444 | { 445 | $tokenParts = (Get-Content -Encoding Unicode -Path $_.FullName).Split('_') 446 | $output = [PSCustomObject] ` 447 | @{ 448 | ACID = $tokenParts[0]; 449 | User = $tokenParts[3] 450 | NotBefore = $tokenParts[4]; 451 | NotAfter = $tokenParts[5]; 452 | } | ConvertTo-Json 453 | Write-Host $output 454 | } 455 | } 456 | function PrintLicensesInformation 457 | { 458 | Param( 459 | [ValidateSet("NUL", "Device")] 460 | [String]$mode 461 | ) 462 | If ($mode -Eq "NUL") 463 | { 464 | $licensePath = "${env:LOCALAPPDATA}\Microsoft\Office\Licenses" 465 | } 466 | ElseIf ($mode -Eq "Device") 467 | { 468 | $licensePath = "${env:PROGRAMDATA}\Microsoft\Office\Licenses" 469 | } 470 | $licenseFiles = $null 471 | If (Test-Path $licensePath) 472 | { 473 | $licenseFiles = Get-ChildItem -Path $licensePath -Recurse -File 474 | } 475 | If ($licenseFiles.length -Eq 0) 476 | { 477 | Write-Host "No licenses found." 478 | Return 479 | } 480 | $licenseFiles | ForEach ` 481 | { 482 | $license = (Get-Content -Encoding Unicode $_.FullName | ConvertFrom-Json).License 483 | $decodedLicense = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($license)) | ConvertFrom-Json 484 | $licenseType = $decodedLicense.LicenseType 485 | If ($null -Ne $decodedLicense.ExpiresOn) 486 | { 487 | $expiry = [DateTime]::Parse($decodedLicense.ExpiresOn, $null, 48) 488 | } 489 | Else 490 | { 491 | $expiry = New-Object DateTime 492 | } 493 | $licenseState = $null 494 | If ((Get-Date) -Gt (Get-Date $decodedLicense.MetaData.NotAfter)) 495 | { 496 | $licenseState = "RFM" 497 | } 498 | ElseIf ((Get-Date) -Lt (Get-Date $expiry)) 499 | { 500 | $licenseState = "Licensed" 501 | } 502 | Else 503 | { 504 | $licenseState = "Grace" 505 | } 506 | if ($mode -Eq "NUL") 507 | { 508 | $output = [PSCustomObject] ` 509 | @{ 510 | Version = $_.Directory.Name 511 | Type = "User|${licenseType}"; 512 | Product = $decodedLicense.ProductReleaseId; 513 | Acid = $decodedLicense.Acid; 514 | LicenseState = $licenseState; 515 | EntitlementStatus = $decodedLicense.Status; 516 | EntitlementExpiration = $decodedLicense.ExpiresOn; 517 | ReasonCode = $decodedLicense.ReasonCode; 518 | NotBefore = $decodedLicense.Metadata.NotBefore; 519 | NotAfter = $decodedLicense.Metadata.NotAfter; 520 | NextRenewal = $decodedLicense.Metadata.RenewAfter; 521 | TenantId = $decodedLicense.Metadata.TenantId; 522 | } | ConvertTo-Json 523 | } 524 | ElseIf ($mode -Eq "Device") 525 | { 526 | $output = [PSCustomObject] ` 527 | @{ 528 | Version = $_.Directory.Name 529 | Type = "Device|${licenseType}"; 530 | Product = $decodedLicense.ProductReleaseId; 531 | Acid = $decodedLicense.Acid; 532 | DeviceId = $decodedLicense.Metadata.DeviceId; 533 | LicenseState = $licenseState; 534 | EntitlementStatus = $decodedLicense.Status; 535 | EntitlementExpiration = $decodedLicense.ExpiresOn; 536 | ReasonCode = $decodedLicense.ReasonCode; 537 | NotBefore = $decodedLicense.Metadata.NotBefore; 538 | NotAfter = $decodedLicense.Metadata.NotAfter; 539 | NextRenewal = $decodedLicense.Metadata.RenewAfter; 540 | TenantId = $decodedLicense.Metadata.TenantId; 541 | } | ConvertTo-Json 542 | } 543 | Write-Output $output 544 | } 545 | } 546 | Write-Host 547 | Write-Host "========== Mode per ProductReleaseId ==========" 548 | Write-Host 549 | PrintModePerPridFromRegistry 550 | Write-Host 551 | Write-Host "========== Shared Computer Licensing ==========" 552 | Write-Host 553 | PrintSharedComputerLicensing 554 | Write-Host 555 | Write-Host "========== vNext licenses ==========" 556 | Write-Host 557 | PrintLicensesInformation -Mode "NUL" 558 | Write-Host 559 | Write-Host "========== Device licenses ==========" 560 | Write-Host 561 | PrintLicensesInformation -Mode "Device" 562 | :vNextDiag: 563 | ::=================================================== 564 | :: Leave empty line below 565 | -------------------------------------------------------------------------------- /MAS/Separate-Files-Version/Extract_OEM_Folder.cmd: -------------------------------------------------------------------------------- 1 | @set masver=2.6 2 | @setlocal DisableDelayedExpansion 3 | @echo off 4 | 5 | 6 | 7 | ::============================================================================ 8 | :: 9 | :: This script is a part of 'Microsoft-Activation-Scripts' (MAS) project. 10 | :: 11 | :: Homepage: mass grave[.]dev 12 | :: Email: windowsaddict@protonmail.com 13 | :: 14 | ::============================================================================ 15 | 16 | 17 | 18 | ::======================================================================================================================================== 19 | 20 | :: Set Path variable, it helps if it is misconfigured in the system 21 | 22 | set "PATH=%SystemRoot%\System32;%SystemRoot%\System32\wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" 23 | if exist "%SystemRoot%\Sysnative\reg.exe" ( 24 | set "PATH=%SystemRoot%\Sysnative;%SystemRoot%\Sysnative\wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%PATH%" 25 | ) 26 | 27 | :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows 28 | :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows 29 | 30 | set "_cmdf=%~f0" 31 | for %%# in (%*) do ( 32 | if /i "%%#"=="r1" set r1=1 33 | if /i "%%#"=="r2" set r2=1 34 | if /i "%%#"=="-qedit" ( 35 | reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "1" /f %nul1% 36 | rem check the code below admin elevation to understand why it's here 37 | ) 38 | ) 39 | 40 | if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 ( 41 | setlocal EnableDelayedExpansion 42 | start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1" 43 | exit /b 44 | ) 45 | 46 | :: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows 47 | 48 | if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined r2 ( 49 | setlocal EnableDelayedExpansion 50 | start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* r2" 51 | exit /b 52 | ) 53 | 54 | ::======================================================================================================================================== 55 | 56 | set "blank=" 57 | set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" 58 | 59 | :: Check if Null service is working, it's important for the batch script 60 | 61 | sc query Null | find /i "RUNNING" 62 | if %errorlevel% NEQ 0 ( 63 | echo: 64 | echo Null service is not running, script may crash... 65 | echo: 66 | echo: 67 | echo Help - %mas%troubleshoot.html 68 | echo: 69 | echo: 70 | ping 127.0.0.1 -n 10 71 | ) 72 | cls 73 | 74 | :: Check LF line ending 75 | 76 | pushd "%~dp0" 77 | >nul findstr /v "$" "%~nx0" && ( 78 | echo: 79 | echo Error: Script either has LF line ending issue or an empty line at the end of the script is missing. 80 | echo: 81 | ping 127.0.0.1 -n 6 >nul 82 | popd 83 | exit /b 84 | ) 85 | popd 86 | 87 | ::======================================================================================================================================== 88 | 89 | cls 90 | color 07 91 | title Extract $OEM$ Folder %masver% 92 | 93 | set _args= 94 | set _elev= 95 | 96 | set _args=%* 97 | if defined _args set _args=%_args:"=% 98 | if defined _args ( 99 | for %%A in (%_args%) do ( 100 | if /i "%%A"=="-el" set _elev=1 101 | ) 102 | ) 103 | 104 | set "nul1=1>nul" 105 | set "nul2=2>nul" 106 | set "nul6=2^>nul" 107 | set "nul=>nul 2>&1" 108 | 109 | set psc=powershell.exe 110 | set winbuild=1 111 | for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G 112 | 113 | set _NCS=1 114 | if %winbuild% LSS 10586 set _NCS=0 115 | if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) 116 | 117 | if %_NCS% EQU 1 ( 118 | for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" 119 | set "Red="41;97m"" 120 | set "Gray="100;97m"" 121 | set "Green="42;97m"" 122 | set "Blue="44;97m"" 123 | set "_White="40;37m"" 124 | set "_Green="40;92m"" 125 | set "_Yellow="40;93m"" 126 | ) else ( 127 | set "Red="Red" "white"" 128 | set "Gray="Darkgray" "white"" 129 | set "Green="DarkGreen" "white"" 130 | set "Blue="Blue" "white"" 131 | set "_White="Black" "Gray"" 132 | set "_Green="Black" "Green"" 133 | set "_Yellow="Black" "Yellow"" 134 | ) 135 | 136 | set "nceline=echo: &echo ==== ERROR ==== &echo:" 137 | set "eline=echo: &call :ex_color %Red% "==== ERROR ====" &echo:" 138 | 139 | ::======================================================================================================================================== 140 | 141 | if %winbuild% LSS 7600 ( 142 | %nceline% 143 | echo Unsupported OS version detected [%winbuild%]. 144 | echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalent. 145 | goto done2 146 | ) 147 | 148 | for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" ( 149 | %nceline% 150 | echo Unable to find powershell.exe in the system. 151 | goto done2 152 | ) 153 | 154 | ::======================================================================================================================================== 155 | 156 | :: Fix special characters limitation in path name 157 | 158 | set "_work=%~dp0" 159 | if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%" 160 | 161 | set "_batf=%~f0" 162 | set "_batp=%_batf:'=''%" 163 | 164 | set _PSarg="""%~f0""" -el %_args% 165 | set "_ttemp=%userprofile%\AppData\Local\Temp" 166 | 167 | setlocal EnableDelayedExpansion 168 | 169 | ::======================================================================================================================================== 170 | 171 | echo "!_batf!" | find /i "!_ttemp!" %nul1% && ( 172 | if /i not "!_work!"=="!_ttemp!" ( 173 | %eline% 174 | echo Script is launched from the temp folder, 175 | echo Most likely you are running the script directly from the archive file. 176 | echo: 177 | echo Extract the archive file and launch the script from the extracted folder. 178 | goto done2 179 | ) 180 | ) 181 | 182 | ::======================================================================================================================================== 183 | 184 | :: Elevate script as admin and pass arguments and preventing loop 185 | 186 | %nul1% fltmc || ( 187 | if not defined _elev %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b 188 | %eline% 189 | echo This script needs admin rights. 190 | echo To do so, right click on this script and select 'Run as administrator'. 191 | goto done2 192 | ) 193 | 194 | ::======================================================================================================================================== 195 | 196 | :: This code disables QuickEdit for this cmd.exe session only without making permanent changes to the registry 197 | :: It is added because clicking on the script window pauses the operation and leads to the confusion that script stopped due to an error 198 | 199 | for %%# in (%_args%) do (if /i "%%#"=="-qedit" set quedit=1) 200 | 201 | reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% || if not defined quedit ( 202 | reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "0" /f %nul1% 203 | start cmd.exe /c ""!_batf!" %_args% -qedit" 204 | rem quickedit reset code is added at the starting of the script instead of here because it takes time to reflect in some cases 205 | exit /b 206 | ) 207 | 208 | ::======================================================================================================================================== 209 | 210 | :: Check for updates 211 | 212 | set -= 213 | set old= 214 | 215 | for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do ( 216 | if not [%%#]==[] (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1)) 217 | ) 218 | 219 | if defined old ( 220 | echo ________________________________________________ 221 | %eline% 222 | echo You are running outdated version MAS %masver% 223 | echo ________________________________________________ 224 | echo: 225 | echo [1] Get Latest MAS 226 | echo [0] Continue Anyway 227 | echo: 228 | call :ex_color %_Green% "Enter a menu option in the Keyboard [1,0] :" 229 | choice /C:10 /N 230 | if !errorlevel!==2 rem 231 | if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) 232 | ) 233 | cls 234 | 235 | ::======================================================================================================================================== 236 | 237 | setlocal DisableDelayedExpansion 238 | 239 | :: Check desktop location 240 | 241 | set desktop= 242 | 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" 243 | if not defined desktop for /f "delims=" %%a in ('%psc% "& {write-host $([Environment]::GetFolderPath('Desktop'))}"') do call set "desktop=%%a" 244 | 245 | set "_pdesk=%desktop:'=''%" 246 | set "_dir=%desktop%\$OEM$\$$\Setup\Scripts" 247 | 248 | if exist "!desktop!\" ( 249 | %eline% 250 | echo Desktop location was not detected, aborting... 251 | goto done2 252 | ) 253 | 254 | setlocal EnableDelayedExpansion 255 | 256 | ::======================================================================================================================================== 257 | 258 | mode con cols=78 lines=30 259 | 260 | if exist "!desktop!\$OEM$\" ( 261 | echo _____________________________________________________ 262 | %eline% 263 | echo $OEM$ folder already exists on the Desktop. 264 | echo _____________________________________________________ 265 | goto done2 266 | ) 267 | 268 | set HWID_Activation.cmd=Activators\HWID_Activation.cmd 269 | set KMS38_Activation.cmd=Activators\KMS38_Activation.cmd 270 | set Online_KMS_Activation.cmd=Activators\Online_KMS_Activation.cmd 271 | set Ohook_Activation_AIO.cmd=Activators\Ohook_Activation_AIO.cmd 272 | pushd "!_work!" 273 | 274 | set _nofile= 275 | for %%# in ( 276 | %HWID_Activation.cmd% 277 | %KMS38_Activation.cmd% 278 | %Online_KMS_Activation.cmd% 279 | %Ohook_Activation_AIO.cmd% 280 | ) do ( 281 | if not exist "%%#" set _nofile=1 282 | ) 283 | 284 | popd 285 | 286 | if defined _nofile ( 287 | echo _____________________________________________________ 288 | %eline% 289 | echo Some files are missing in the 'Activators' folder. 290 | echo _____________________________________________________ 291 | goto done2 292 | ) 293 | 294 | ::======================================================================================================================================== 295 | 296 | :Menu 297 | 298 | cls 299 | mode con cols=78 lines=30 300 | echo: 301 | echo: 302 | echo: 303 | echo: 304 | echo: Extract $OEM$ folder on the desktop 305 | echo: ________________________________________________________ 306 | echo: 307 | echo: [1] HWID 308 | echo: [2] Ohook 309 | echo: [3] KMS38 310 | echo: [4] Online KMS 311 | echo: 312 | echo: [5] HWID ^(Windows^) ^+ Ohook ^(Office^) 313 | echo: [6] HWID ^(Windows^) ^+ Online KMS ^(Office^) 314 | echo: [7] KMS38 ^(Windows^) ^+ Ohook ^(Office^) 315 | echo: [8] KMS38 ^(Windows^) ^+ Online KMS ^(Office^) 316 | echo: [9] Online KMS ^(Windows^) ^+ Ohook ^(Office^) 317 | echo: 318 | call :ex_color2 %_White% " [R] " %_Green% "ReadMe" 319 | echo: [0] Exit 320 | echo: ________________________________________________________ 321 | echo: 322 | call :ex_color2 %_White% " " %_Green% "Enter a menu option in the Keyboard :" 323 | choice /C:123456789R0 /N 324 | set _erl=%errorlevel% 325 | 326 | if %_erl%==11 exit /b 327 | if %_erl%==10 start %mas%oem-folder.html &goto :Menu 328 | if %_erl%==9 goto:kms_ohook 329 | if %_erl%==8 goto:kms38_kms 330 | if %_erl%==7 goto:kms38_ohook 331 | if %_erl%==6 goto:hwid_kms 332 | if %_erl%==5 goto:hwid_ohook 333 | if %_erl%==4 goto:kms 334 | if %_erl%==3 goto:kms38 335 | if %_erl%==2 goto:ohook 336 | if %_erl%==1 goto:hwid 337 | goto :Menu 338 | 339 | ::======================================================================================================================================== 340 | 341 | :hwid 342 | 343 | cls 344 | md "!desktop!\$OEM$\$$\Setup\Scripts" 345 | pushd "!_work!" 346 | copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul% 347 | popd 348 | call :export hwid_setup 349 | 350 | set _error= 351 | if not exist "!_dir!\HWID_Activation.cmd" set _error=1 352 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 353 | if defined _error goto errorfound 354 | 355 | set oem=HWID 356 | goto done 357 | 358 | :hwid_setup: 359 | @echo off 360 | 361 | fltmc >nul || exit /b 362 | 363 | call "%~dp0HWID_Activation.cmd" /HWID 364 | 365 | cd \ 366 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 367 | :hwid_setup: 368 | 369 | ::======================================================================================================================================== 370 | 371 | :ohook 372 | 373 | cls 374 | md "!desktop!\$OEM$\$$\Setup\Scripts" 375 | pushd "!_work!" 376 | copy /y /b %Ohook_Activation_AIO.cmd% "!_dir!\Ohook_Activation_AIO.cmd" %nul% 377 | popd 378 | call :export ohook_setup 379 | 380 | set _error= 381 | if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1 382 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 383 | if defined _error goto errorfound 384 | 385 | set oem=Ohook 386 | goto done 387 | 388 | :ohook_setup: 389 | @echo off 390 | 391 | fltmc >nul || exit /b 392 | 393 | call "%~dp0Ohook_Activation_AIO.cmd" /Ohook 394 | 395 | cd \ 396 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 397 | :ohook_setup: 398 | 399 | ::======================================================================================================================================== 400 | 401 | :kms38 402 | 403 | cls 404 | md "!desktop!\$OEM$\$$\Setup\Scripts" 405 | pushd "!_work!" 406 | copy /y /b "%KMS38_Activation.cmd%" "!_dir!\KMS38_Activation.cmd" %nul% 407 | popd 408 | call :export kms38_setup 409 | 410 | set _error= 411 | if not exist "!_dir!\KMS38_Activation.cmd" set _error=1 412 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 413 | if defined _error goto errorfound 414 | 415 | set oem=KMS38 416 | goto done 417 | 418 | :kms38_setup: 419 | @echo off 420 | 421 | fltmc >nul || exit /b 422 | 423 | call "%~dp0KMS38_Activation.cmd" /KMS38 424 | 425 | cd \ 426 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 427 | :kms38_setup: 428 | 429 | ::======================================================================================================================================== 430 | 431 | :kms 432 | 433 | cls 434 | md "!desktop!\$OEM$\$$\Setup\Scripts" 435 | pushd "!_work!" 436 | copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul% 437 | popd 438 | call :export kms_setup 439 | 440 | set _error= 441 | if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1 442 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 443 | if defined _error goto errorfound 444 | 445 | set oem=Online KMS 446 | goto done 447 | 448 | :kms_setup: 449 | @echo off 450 | 451 | fltmc >nul || exit /b 452 | 453 | call "%~dp0Online_KMS_Activation.cmd" /KMS-ActAndRenewalTask /KMS-WindowsOffice 454 | 455 | cd \ 456 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 457 | :kms_setup: 458 | 459 | ::======================================================================================================================================== 460 | 461 | :hwid_ohook 462 | 463 | cls 464 | md "!desktop!\$OEM$\$$\Setup\Scripts" 465 | pushd "!_work!" 466 | copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul% 467 | copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul% 468 | popd 469 | call :export hwid_ohook_setup 470 | 471 | set _error= 472 | if not exist "!_dir!\HWID_Activation.cmd" set _error=1 473 | if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1 474 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 475 | if defined _error goto errorfound 476 | 477 | set oem=HWID [Windows] + Ohook [Office] 478 | goto done 479 | 480 | :hwid_ohook_setup: 481 | @echo off 482 | 483 | fltmc >nul || exit /b 484 | 485 | setlocal 486 | call "%~dp0HWID_Activation.cmd" /HWID 487 | endlocal 488 | 489 | setlocal 490 | call "%~dp0Ohook_Activation_AIO.cmd" /Ohook 491 | endlocal 492 | 493 | cd \ 494 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 495 | :hwid_ohook_setup: 496 | 497 | ::======================================================================================================================================== 498 | 499 | :hwid_kms 500 | 501 | cls 502 | md "!desktop!\$OEM$\$$\Setup\Scripts" 503 | pushd "!_work!" 504 | copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul% 505 | copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul% 506 | popd 507 | call :export hwid_kms_setup 508 | 509 | set _error= 510 | if not exist "!_dir!\HWID_Activation.cmd" set _error=1 511 | if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1 512 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 513 | if defined _error goto errorfound 514 | 515 | set oem=HWID [Windows] + Online KMS [Office] 516 | goto done 517 | 518 | :hwid_kms_setup: 519 | @echo off 520 | 521 | fltmc >nul || exit /b 522 | 523 | setlocal 524 | call "%~dp0HWID_Activation.cmd" /HWID 525 | endlocal 526 | 527 | setlocal 528 | call "%~dp0Online_KMS_Activation.cmd" /KMS-ActAndRenewalTask /KMS-Office 529 | endlocal 530 | 531 | cd \ 532 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 533 | :hwid_kms_setup: 534 | 535 | ::======================================================================================================================================== 536 | 537 | :kms38_ohook 538 | 539 | cls 540 | md "!desktop!\$OEM$\$$\Setup\Scripts" 541 | pushd "!_work!" 542 | copy /y /b "%KMS38_Activation.cmd%" "!_dir!\KMS38_Activation.cmd" %nul% 543 | copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul% 544 | popd 545 | call :export kms38_ohook_setup 546 | 547 | set _error= 548 | if not exist "!_dir!\KMS38_Activation.cmd" set _error=1 549 | if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1 550 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 551 | if defined _error goto errorfound 552 | 553 | set oem=KMS38 [Windows] + Ohook [Office] 554 | goto done 555 | 556 | :kms38_ohook_setup: 557 | @echo off 558 | 559 | fltmc >nul || exit /b 560 | 561 | setlocal 562 | call "%~dp0KMS38_Activation.cmd" /KMS38 563 | endlocal 564 | 565 | setlocal 566 | call "%~dp0Ohook_Activation_AIO.cmd" /Ohook 567 | endlocal 568 | 569 | cd \ 570 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 571 | :kms38_ohook_setup: 572 | 573 | ::======================================================================================================================================== 574 | 575 | :kms38_kms 576 | 577 | cls 578 | md "!desktop!\$OEM$\$$\Setup\Scripts" 579 | pushd "!_work!" 580 | copy /y /b "%KMS38_Activation.cmd%" "!_dir!\KMS38_Activation.cmd" %nul% 581 | copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul% 582 | popd 583 | call :export kms38_kms_setup 584 | 585 | set _error= 586 | if not exist "!_dir!\KMS38_Activation.cmd" set _error=1 587 | if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1 588 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 589 | if defined _error goto errorfound 590 | 591 | set oem=KMS38 [Windows] + Online KMS [Office] 592 | goto done 593 | 594 | :kms38_kms_setup: 595 | @echo off 596 | 597 | fltmc >nul || exit /b 598 | 599 | setlocal 600 | call "%~dp0KMS38_Activation.cmd" /KMS38 601 | endlocal 602 | 603 | setlocal 604 | call "%~dp0Online_KMS_Activation.cmd" /KMS-ActAndRenewalTask /KMS-Office 605 | endlocal 606 | 607 | cd \ 608 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 609 | :kms38_kms_setup: 610 | 611 | ::======================================================================================================================================== 612 | 613 | :kms_ohook 614 | 615 | cls 616 | md "!desktop!\$OEM$\$$\Setup\Scripts" 617 | pushd "!_work!" 618 | copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul% 619 | copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul% 620 | popd 621 | call :export kms_ohook_setup 622 | 623 | set _error= 624 | if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1 625 | if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1 626 | if not exist "!_dir!\SetupComplete.cmd" set _error=1 627 | if defined _error goto errorfound 628 | 629 | set oem=Online KMS [Windows] + Ohook [Office] 630 | goto done 631 | 632 | :kms_ohook_setup: 633 | @echo off 634 | 635 | fltmc >nul || exit /b 636 | 637 | setlocal 638 | call "%~dp0Online_KMS_Activation.cmd" /KMS-ActAndRenewalTask /KMS-Windows 639 | endlocal 640 | 641 | setlocal 642 | call "%~dp0Ohook_Activation_AIO.cmd" /Ohook 643 | endlocal 644 | 645 | cd \ 646 | (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") 647 | :kms_ohook_setup: 648 | 649 | ::======================================================================================================================================== 650 | 651 | :errorfound 652 | 653 | %eline% 654 | echo $OEM$ Folder was not created successfully... 655 | goto :done2 656 | 657 | :done 658 | 659 | echo ______________________________________________________________ 660 | echo: 661 | call :ex_color %Blue% "%oem%" 662 | call :ex_color %Green% "$OEM$ folder is successfully created on the Desktop." 663 | echo "%oem%" | find /i "38" %nul% && ( 664 | echo: 665 | echo To KMS38 activate Server Cor/Acor editions ^(No GUI Versions^), 666 | echo Check this page %mas%oem-folder 667 | ) 668 | echo ______________________________________________________________ 669 | 670 | :done2 671 | 672 | echo: 673 | call :ex_color %_Yellow% "Press any key to exit..." 674 | pause %nul1% 675 | exit /b 676 | 677 | ::======================================================================================================================================== 678 | 679 | :: Extract the text from batch script without character and file encoding issue 680 | 681 | :export 682 | 683 | %psc% "$f=[io.file]::ReadAllText('!_batp!') -split \":%~1\:.*`r`n\"; [io.file]::WriteAllText('!_pdesk!\$OEM$\$$\Setup\Scripts\SetupComplete.cmd',$f[1].Trim(),[System.Text.Encoding]::ASCII);" 684 | exit /b 685 | 686 | ::======================================================================================================================================== 687 | 688 | :ex_color 689 | 690 | if %_NCS% EQU 1 ( 691 | echo %esc%[%~1%~2%esc%[0m 692 | ) else ( 693 | if not exist %psc% (echo %~3) else (%psc% write-host -back '%1' -fore '%2' '%3') 694 | ) 695 | exit /b 696 | 697 | :ex_color2 698 | 699 | if %_NCS% EQU 1 ( 700 | echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m 701 | ) else ( 702 | if not exist %psc% (echo %~3%~6) else (%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6') 703 | ) 704 | exit /b 705 | 706 | ::======================================================================================================================================== 707 | :: Leave empty line below 708 | -------------------------------------------------------------------------------- /MAS/Separate-Files-Version/Troubleshoot.cmd: -------------------------------------------------------------------------------- 1 | @set masver=2.6 2 | @setlocal DisableDelayedExpansion 3 | @echo off 4 | 5 | 6 | 7 | ::============================================================================ 8 | :: 9 | :: This script is a part of 'Microsoft-Activation-Scripts' (MAS) project. 10 | :: 11 | :: Homepage: mass grave[.]dev 12 | :: Email: windowsaddict@protonmail.com 13 | :: 14 | ::============================================================================ 15 | 16 | 17 | 18 | ::======================================================================================================================================== 19 | 20 | :: Set Path variable, it helps if it is misconfigured in the system 21 | 22 | set "PATH=%SystemRoot%\System32;%SystemRoot%\System32\wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" 23 | if exist "%SystemRoot%\Sysnative\reg.exe" ( 24 | set "PATH=%SystemRoot%\Sysnative;%SystemRoot%\Sysnative\wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%PATH%" 25 | ) 26 | 27 | :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows 28 | :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows 29 | 30 | set "_cmdf=%~f0" 31 | for %%# in (%*) do ( 32 | if /i "%%#"=="r1" set r1=1 33 | if /i "%%#"=="r2" set r2=1 34 | if /i "%%#"=="-qedit" ( 35 | reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "1" /f %nul1% 36 | rem check the code below admin elevation to understand why it's here 37 | ) 38 | ) 39 | 40 | if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 ( 41 | setlocal EnableDelayedExpansion 42 | start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1" 43 | exit /b 44 | ) 45 | 46 | :: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows 47 | 48 | if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined r2 ( 49 | setlocal EnableDelayedExpansion 50 | start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* r2" 51 | exit /b 52 | ) 53 | 54 | ::======================================================================================================================================== 55 | 56 | set "blank=" 57 | set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" 58 | 59 | :: Check if Null service is working, it's important for the batch script 60 | 61 | sc query Null | find /i "RUNNING" 62 | if %errorlevel% NEQ 0 ( 63 | echo: 64 | echo Null service is not running, script may crash... 65 | echo: 66 | echo: 67 | echo Help - %mas%troubleshoot.html 68 | echo: 69 | echo: 70 | ping 127.0.0.1 -n 10 71 | ) 72 | cls 73 | 74 | :: Check LF line ending 75 | 76 | pushd "%~dp0" 77 | >nul findstr /v "$" "%~nx0" && ( 78 | echo: 79 | echo Error: Script either has LF line ending issue or an empty line at the end of the script is missing. 80 | echo: 81 | ping 127.0.0.1 -n 6 >nul 82 | popd 83 | exit /b 84 | ) 85 | popd 86 | 87 | ::======================================================================================================================================== 88 | 89 | cls 90 | color 07 91 | title Troubleshoot %masver% 92 | 93 | set _args= 94 | set _elev= 95 | 96 | set _args=%* 97 | if defined _args set _args=%_args:"=% 98 | if defined _args ( 99 | for %%A in (%_args%) do ( 100 | if /i "%%A"=="-el" set _elev=1 101 | ) 102 | ) 103 | 104 | set "nul1=1>nul" 105 | set "nul2=2>nul" 106 | set "nul6=2^>nul" 107 | set "nul=>nul 2>&1" 108 | 109 | set psc=powershell.exe 110 | set winbuild=1 111 | for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G 112 | 113 | set _NCS=1 114 | if %winbuild% LSS 10586 set _NCS=0 115 | if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) 116 | 117 | call :_colorprep 118 | 119 | set "nceline=echo: &echo ==== ERROR ==== &echo:" 120 | set "eline=echo: &call :_color %Red% "==== ERROR ====" &echo:" 121 | set "line=_________________________________________________________________________________________________" 122 | if %~z0 GEQ 200000 (set "_exitmsg=Go back") else (set "_exitmsg=Exit") 123 | 124 | ::======================================================================================================================================== 125 | 126 | if %winbuild% LSS 7600 ( 127 | %nceline% 128 | echo Unsupported OS version detected [%winbuild%]. 129 | echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalent. 130 | goto at_done 131 | ) 132 | 133 | for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" ( 134 | %nceline% 135 | echo Unable to find powershell.exe in the system. 136 | goto at_done 137 | ) 138 | 139 | ::======================================================================================================================================== 140 | 141 | :: Fix special characters limitation in path name 142 | 143 | set "_work=%~dp0" 144 | if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%" 145 | 146 | set "_batf=%~f0" 147 | set "_batp=%_batf:'=''%" 148 | 149 | set _PSarg="""%~f0""" -el %_args% 150 | 151 | set "_ttemp=%userprofile%\AppData\Local\Temp" 152 | 153 | setlocal EnableDelayedExpansion 154 | 155 | ::======================================================================================================================================== 156 | 157 | echo "!_batf!" | find /i "!_ttemp!" %nul1% && ( 158 | if /i not "!_work!"=="!_ttemp!" ( 159 | %nceline% 160 | echo Script is launched from the temp folder, 161 | echo Most likely you are running the script directly from the archive file. 162 | echo: 163 | echo Extract the archive file and launch the script from the extracted folder. 164 | goto at_done 165 | ) 166 | ) 167 | 168 | ::======================================================================================================================================== 169 | 170 | :: Elevate script as admin and pass arguments and preventing loop 171 | 172 | %nul1% fltmc || ( 173 | if not defined _elev %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b 174 | %nceline% 175 | echo This script needs admin rights. 176 | echo To do so, right click on this script and select 'Run as administrator'. 177 | goto at_done 178 | ) 179 | 180 | ::======================================================================================================================================== 181 | 182 | :: This code disables QuickEdit for this cmd.exe session only without making permanent changes to the registry 183 | :: It is added because clicking on the script window pauses the operation and leads to the confusion that script stopped due to an error 184 | 185 | for %%# in (%_args%) do (if /i "%%#"=="-qedit" set quedit=1) 186 | 187 | reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% || if not defined quedit ( 188 | reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "0" /f %nul1% 189 | start cmd.exe /c ""!_batf!" %_args% -qedit" 190 | rem quickedit reset code is added at the starting of the script instead of here because it takes time to reflect in some cases 191 | exit /b 192 | ) 193 | 194 | ::======================================================================================================================================== 195 | 196 | :: Check for updates 197 | 198 | set -= 199 | set old= 200 | 201 | for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do ( 202 | if not [%%#]==[] (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1)) 203 | ) 204 | 205 | if defined old ( 206 | echo ________________________________________________ 207 | %eline% 208 | echo You are running outdated version MAS %masver% 209 | echo ________________________________________________ 210 | echo: 211 | echo [1] Get Latest MAS 212 | echo [0] Continue Anyway 213 | echo: 214 | call :_color %_Green% "Enter a menu option in the Keyboard [1,0] :" 215 | choice /C:10 /N 216 | if !errorlevel!==2 rem 217 | if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) 218 | ) 219 | cls 220 | 221 | ::======================================================================================================================================== 222 | 223 | setlocal DisableDelayedExpansion 224 | 225 | :: Check desktop location 226 | 227 | set desktop= 228 | 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" 229 | if not defined desktop for /f "delims=" %%a in ('%psc% "& {write-host $([Environment]::GetFolderPath('Desktop'))}"') do call set "desktop=%%a" 230 | 231 | if not defined desktop ( 232 | %eline% 233 | echo Desktop location was not detected, aborting... 234 | goto at_done 235 | ) 236 | 237 | setlocal EnableDelayedExpansion 238 | 239 | ::======================================================================================================================================== 240 | 241 | :at_menu 242 | 243 | cls 244 | color 07 245 | title Troubleshoot %masver% 246 | mode con cols=77 lines=30 247 | 248 | echo: 249 | echo: 250 | echo: 251 | echo: 252 | echo: _______________________________________________________________ 253 | echo: 254 | call :_color2 %_White% " [1] " %_Green% "Help" 255 | echo: ___________________________________________________ 256 | echo: 257 | echo: [2] Dism RestoreHealth 258 | echo: [3] SFC Scannow 259 | echo: 260 | echo: [4] Fix WMI 261 | echo: [5] Fix Licensing 262 | echo: [6] Fix WPA Registry 263 | echo: ___________________________________________________ 264 | echo: 265 | echo: [0] %_exitmsg% 266 | echo: _______________________________________________________________ 267 | echo: 268 | call :_color2 %_White% " " %_Green% "Enter a menu option in the Keyboard :" 269 | choice /C:1234560 /N 270 | set _erl=%errorlevel% 271 | 272 | if %_erl%==7 exit /b 273 | if %_erl%==6 start %mas%fix-wpa-registry.html &goto at_menu 274 | if %_erl%==5 goto:retokens 275 | if %_erl%==4 goto:fixwmi 276 | if %_erl%==3 goto:sfcscan 277 | if %_erl%==2 goto:dism_rest 278 | if %_erl%==1 start %mas%troubleshoot.html &goto at_menu 279 | goto :at_menu 280 | 281 | ::======================================================================================================================================== 282 | 283 | :dism_rest 284 | 285 | cls 286 | mode 98, 30 287 | title Dism /English /Online /Cleanup-Image /RestoreHealth 288 | 289 | if %winbuild% LSS 9200 ( 290 | %eline% 291 | echo Unsupported OS version Detected. 292 | echo This command is supported only for Windows 8/8.1/10/11 and their Server equivalent. 293 | goto :at_back 294 | ) 295 | 296 | set _int= 297 | for %%a in (l.root-servers.net resolver1.opendns.com download.windowsupdate.com google.com) do if not defined _int ( 298 | for /f "delims=[] tokens=2" %%# in ('ping -n 1 %%a') do (if not [%%#]==[] set _int=1) 299 | ) 300 | 301 | echo: 302 | if defined _int ( 303 | echo Checking Internet Connection [Connected] 304 | ) else ( 305 | call :_color2 %_White% " " %Red% "Checking Internet Connection [Not connected]" 306 | ) 307 | 308 | echo %line% 309 | echo: 310 | echo Dism uses Windows Update to provide the files required to fix corruption. 311 | echo This will take 5-15 minutes or more.. 312 | echo %line% 313 | echo: 314 | echo Notes: 315 | echo: 316 | call :_color2 %_White% " - " %Gray% "Make sure the Internet is connected." 317 | call :_color2 %_White% " - " %Gray% "Make sure the Windows update is properly working." 318 | echo: 319 | echo %line% 320 | echo: 321 | choice /C:09 /N /M "> [9] Continue [0] Go back : " 322 | if %errorlevel%==1 goto at_menu 323 | 324 | cls 325 | mode 110, 30 326 | %psc% Stop-Service TrustedInstaller -force %nul% 327 | 328 | set _time= 329 | for /f %%a in ('%psc% "Get-Date -format HH_mm_ss"') do set _time=%%a 330 | echo: 331 | echo Applying the command, 332 | echo dism /english /online /cleanup-image /restorehealth 333 | dism /english /online /cleanup-image /restorehealth 334 | 335 | %psc% Stop-Service TrustedInstaller -force %nul% 336 | 337 | if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul% 338 | 339 | call :compresslog cbs\CBS.log RHealth_CBS %nul% 340 | call :compresslog DISM\dism.log RHealth_DISM %nul% 341 | 342 | if not exist "!desktop!\AT_Logs\RHealth_CBS_%_time%.cab" ( 343 | copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "!desktop!\AT_Logs\RHealth_CBS_%_time%.log" %nul% 344 | ) 345 | 346 | if not exist "!desktop!\AT_Logs\RHealth_DISM_%_time%.cab" ( 347 | copy /y /b "%SystemRoot%\logs\DISM\dism.log" "!desktop!\AT_Logs\RHealth_DISM_%_time%.log" %nul% 348 | ) 349 | 350 | echo: 351 | call :_color %Gray% "CBS and DISM logs are copied to the AT_Logs folder on the dekstop." 352 | goto :at_back 353 | 354 | ::======================================================================================================================================== 355 | 356 | :sfcscan 357 | 358 | cls 359 | mode 98, 30 360 | title sfc /scannow 361 | 362 | echo: 363 | echo %line% 364 | echo: 365 | echo System File Checker will repair missing or corrupted system files. 366 | echo This will take 10-15 minutes or more.. 367 | echo: 368 | echo If SFC could not fix something, then run the command again to see if it may be able 369 | echo to the next time. Sometimes it may take running the sfc /scannow command 3 times 370 | echo restarting the PC after each time to completely fix everything that it's able to. 371 | echo: 372 | echo %line% 373 | echo: 374 | choice /C:09 /N /M "> [9] Continue [0] Go back : " 375 | if %errorlevel%==1 goto at_menu 376 | 377 | cls 378 | %psc% Stop-Service TrustedInstaller -force %nul% 379 | 380 | set _time= 381 | for /f %%a in ('%psc% "Get-Date -format HH_mm_ss"') do set _time=%%a 382 | echo: 383 | echo Applying the command, 384 | echo sfc /scannow 385 | sfc /scannow 386 | 387 | %psc% Stop-Service TrustedInstaller -force %nul% 388 | 389 | if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul% 390 | 391 | call :compresslog cbs\CBS.log SFC_CBS %nul% 392 | 393 | if not exist "!desktop!\AT_Logs\SFC_CBS_%_time%.cab" ( 394 | copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "!desktop!\AT_Logs\SFC_CBS_%_time%.log" %nul% 395 | ) 396 | 397 | echo: 398 | call :_color %Gray% "CBS log is copied to the AT_Logs folder on the dekstop." 399 | goto :at_back 400 | 401 | ::======================================================================================================================================== 402 | 403 | :retokens 404 | 405 | cls 406 | mode con cols=125 lines=32 407 | %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;}" 408 | title Fix Licensing ^(ClipSVC ^+ Office vNext ^+ SPP ^+ OSPP^) 409 | 410 | echo: 411 | echo %line% 412 | echo: 413 | echo Notes: 414 | echo: 415 | echo - It helps in troubleshooting activation issues. 416 | echo: 417 | echo - This option will, 418 | echo - Deactivate Windows and Office, you may need to reactivate 419 | echo If Windows is activated with motherboard / OEM / Digital license then don't worry 420 | echo: 421 | echo - Clear ClipSVC, Office vNext, SPP and OSPP licenses 422 | echo - Fix SPP permissions of tokens folder and registries 423 | echo - Trigger the repair option for Office. 424 | echo: 425 | call :_color2 %_White% " - " %Red% "Apply it only when it is necessary." 426 | echo: 427 | echo %line% 428 | echo: 429 | choice /C:09 /N /M "> [9] Continue [0] Go back : " 430 | if %errorlevel%==1 goto at_menu 431 | 432 | ::======================================================================================================================================== 433 | 434 | :: Rebuild ClipSVC Licences 435 | 436 | cls 437 | :cleanlicensing 438 | 439 | echo: 440 | echo %line% 441 | echo: 442 | call :_color %Blue% "Rebuilding ClipSVC Licences" 443 | echo: 444 | 445 | if %winbuild% LSS 10240 ( 446 | echo ClipSVC Licence rebuilding is supported only on Win 10/11 and Server equivalent. 447 | echo Skipping... 448 | goto :cleanvnext 449 | ) 450 | 451 | %psc% "(([WMISEARCHER]'SELECT Name FROM SoftwareLicensingProduct WHERE LicenseStatus=1 AND GracePeriodRemaining=0 AND PartialProductKey IS NOT NULL').Get()).Name" %nul2% | findstr /i "Windows" %nul1% && ( 452 | echo Windows is permanently activated. 453 | echo Skipping rebuilding ClipSVC licences... 454 | goto :cleanvnext 455 | ) 456 | 457 | echo Stopping ClipSVC service... 458 | %psc% Stop-Service ClipSVC -force %nul% 459 | timeout /t 2 %nul% 460 | 461 | echo: 462 | echo Applying the command to Clean ClipSVC Licences... 463 | echo rundll32 clipc.dll,ClipCleanUpState 464 | 465 | rundll32 clipc.dll,ClipCleanUpState 466 | 467 | if %winbuild% LEQ 10240 ( 468 | echo [Successful] 469 | ) else ( 470 | if exist "%ProgramData%\Microsoft\Windows\ClipSVC\tokens.dat" ( 471 | call :_color %Red% "[Failed]" 472 | ) else ( 473 | echo [Successful] 474 | ) 475 | ) 476 | 477 | :: Below registry key (Volatile & Protected) gets created after the ClipSVC License cleanup command, and gets automatically deleted after 478 | :: system restart. It needs to be deleted to activate the system without restart. 479 | 480 | set "RegKey=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" 481 | set "_ident=HKU\S-1-5-19\SOFTWARE\Microsoft\IdentityCRL" 482 | 483 | reg query "%RegKey%" %nul% && %nul% call :regownstart 484 | reg delete "%RegKey%" /f %nul% 485 | 486 | echo: 487 | echo Deleting a Volatile ^& Protected Registry Key... 488 | echo [%RegKey%] 489 | reg query "%RegKey%" %nul% && ( 490 | call :_color %Red% "[Failed]" 491 | echo Restart the system, that will delete this registry key automatically. 492 | ) || ( 493 | echo [Successful] 494 | ) 495 | 496 | :: Clear HWID token related registry to fix activation incase if there is any corruption 497 | 498 | echo: 499 | echo Deleting a IdentityCRL Registry Key... 500 | echo [%_ident%] 501 | reg delete "%_ident%" /f %nul% 502 | reg query "%_ident%" %nul% && ( 503 | call :_color %Red% "[Failed]" 504 | ) || ( 505 | echo [Successful] 506 | ) 507 | 508 | %psc% Stop-Service ClipSVC -force %nul% 509 | 510 | :: Rebuild ClipSVC folder to fix permission issues 511 | 512 | echo: 513 | if %winbuild% GTR 10240 ( 514 | echo Deleting Folder %ProgramData%\Microsoft\Windows\ClipSVC\ 515 | rmdir /s /q "C:\ProgramData\Microsoft\Windows\ClipSvc" %nul% 516 | 517 | if exist "%ProgramData%\Microsoft\Windows\ClipSVC\" ( 518 | call :_color %Red% "[Failed]" 519 | ) else ( 520 | echo [Successful] 521 | ) 522 | 523 | echo: 524 | echo Rebuilding Folder %ProgramData%\Microsoft\Windows\ClipSVC\ 525 | %psc% Start-Service ClipSVC %nul% 526 | timeout /t 3 %nul% 527 | if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" timeout /t 5 %nul% 528 | if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" ( 529 | call :_color %Red% "[Failed]" 530 | ) else ( 531 | echo [Successful] 532 | ) 533 | ) 534 | 535 | echo: 536 | echo Restarting [wlidsvc LicenseManager] services... 537 | for %%# in (wlidsvc LicenseManager) do (%psc% Restart-Service %%# %nul%) 538 | 539 | ::======================================================================================================================================== 540 | 541 | :: Find remnants of Office vNext license block and remove it because it stops non vNext licenses from appearing 542 | :: https://learn.microsoft.com/en-us/office/troubleshoot/activation/reset-office-365-proplus-activation-state 543 | 544 | :cleanvnext 545 | 546 | echo: 547 | echo %line% 548 | echo: 549 | call :_color %Blue% "Clearing Office vNext License" 550 | echo: 551 | 552 | setlocal DisableDelayedExpansion 553 | set "_Local=%LocalAppData%" 554 | setlocal EnableDelayedExpansion 555 | 556 | attrib -R "!ProgramData!\Microsoft\Office\Licenses" %nul% 557 | attrib -R "!_Local!\Microsoft\Office\Licenses" %nul% 558 | 559 | if exist "!ProgramData!\Microsoft\Office\Licenses\" ( 560 | rd /s /q "!ProgramData!\Microsoft\Office\Licenses\" %nul% 561 | if exist "!ProgramData!\Microsoft\Office\Licenses\" ( 562 | echo Failed To Delete - !ProgramData!\Microsoft\Office\Licenses\ 563 | ) else ( 564 | echo Deleted Folder - !ProgramData!\Microsoft\Office\Licenses\ 565 | ) 566 | ) else ( 567 | echo Not Found - !ProgramData!\Microsoft\Office\Licenses\ 568 | ) 569 | 570 | if exist "!_Local!\Microsoft\Office\Licenses\" ( 571 | rd /s /q "!_Local!\Microsoft\Office\Licenses\" %nul% 572 | if exist "!_Local!\Microsoft\Office\Licenses\" ( 573 | echo Failed To Delete - !_Local!\Microsoft\Office\Licenses\ 574 | ) else ( 575 | echo Deleted Folder - !_Local!\Microsoft\Office\Licenses\ 576 | ) 577 | ) else ( 578 | echo Not Found - !_Local!\Microsoft\Office\Licenses\ 579 | ) 580 | 581 | 582 | echo: 583 | for /f "tokens=* delims=" %%a in ('%psc% "Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' | ForEach-Object { Split-Path -Path $_.PSPath -Leaf }" %nul6%') do (if defined _sid (set "_sid=!_sid! HKU\%%a") else (set "_sid=HKU\%%a")) 584 | 585 | set regfound= 586 | for %%# in (HKCU !_sid!) do ( 587 | for %%A in ( 588 | %%#\Software\Microsoft\Office\16.0\Common\Licensing 589 | %%#\Software\Microsoft\Office\16.0\Common\Identity 590 | %%#\Software\Microsoft\Office\16.0\Registration 591 | ) do ( 592 | reg query %%A %nul% && ( 593 | set regfound=1 594 | reg delete %%A /f %nul% && ( 595 | echo Deleted Registry - %%A 596 | ) || ( 597 | echo Failed to Delete - %%A 598 | ) 599 | ) 600 | ) 601 | ) 602 | if not defined regfound echo Not Found - Office vNext Registry Keys 603 | 604 | ::======================================================================================================================================== 605 | 606 | :: Rebuild SPP Tokens 607 | 608 | echo: 609 | echo %line% 610 | echo: 611 | call :_color %Blue% "Rebuilding SPP Licensing Tokens" 612 | echo: 613 | 614 | call :scandat check 615 | 616 | if not defined token ( 617 | call :_color %Red% "tokens.dat file not found." 618 | ) else ( 619 | echo tokens.dat file: [%token%] 620 | ) 621 | 622 | echo: 623 | set wpainfo= 624 | for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1]);" %nul6%') do (set wpainfo=%%a) 625 | echo "%wpainfo%" | find /i "Error Found" %nul% && ( 626 | call :_color %Red% "WPA Registry Error: %wpainfo%" 627 | ) || ( 628 | echo WPA Registry Count: %wpainfo% 629 | ) 630 | 631 | set tokenstore= 632 | for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b" 633 | 634 | :: Check sppsvc permissions and apply fixes 635 | 636 | if %winbuild% GEQ 10240 ( 637 | 638 | echo: 639 | echo Checking SPP permission related issues... 640 | call :checkperms 641 | 642 | if defined permerror ( 643 | 644 | mkdir "%tokenstore%" %nul% 645 | set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';" 646 | set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" 647 | set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" 648 | set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" 649 | %psc% "!d!" %nul% 650 | 651 | for %%# in ( 652 | "HKLM:\SYSTEM\WPA_QueryValues, EnumerateSubKeys, WriteKey" 653 | "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform_SetValue" 654 | ) do for /f "tokens=1,2 delims=_" %%A in (%%#) do ( 655 | set "d=$acl = Get-Acl '%%A';" 656 | set "d=!d! $rule = New-Object System.Security.AccessControl.RegistryAccessRule ('NT Service\sppsvc', '%%B', 'ContainerInherit, ObjectInherit','None','Allow');" 657 | set "d=!d! $acl.ResetAccessRule($rule);" 658 | set "d=!d! $acl.SetAccessRule($rule);" 659 | set "d=!d! Set-Acl -Path '%%A' -AclObject $acl" 660 | %psc% "!d!" %nul% 661 | ) 662 | 663 | call :checkperms 664 | if defined permerror ( 665 | call :_color %Red% "[Failed To Fix]" 666 | ) else ( 667 | echo [Successfully Fixed] 668 | ) 669 | ) else ( 670 | echo [No Error Found] 671 | ) 672 | ) 673 | 674 | echo: 675 | echo Stopping sppsvc service... 676 | %psc% Stop-Service sppsvc -force %nul% 677 | 678 | echo: 679 | call :scandat delete 680 | call :scandat check 681 | 682 | if defined token ( 683 | echo: 684 | call :_color %Red% "Failed to delete .dat files." 685 | echo: 686 | ) 687 | 688 | echo: 689 | echo Reinstalling System Licenses [slmgr /rilc]... 690 | cscript //nologo %windir%\system32\slmgr.vbs /rilc %nul% 691 | if %errorlevel% NEQ 0 cscript //nologo %windir%\system32\slmgr.vbs /rilc %nul% 692 | if %errorlevel% EQU 0 ( 693 | echo [Successful] 694 | ) else ( 695 | call :_color %Red% "[Failed]" 696 | ) 697 | 698 | call :scandat check 699 | 700 | echo: 701 | if not defined token ( 702 | call :_color %Red% "Failed to rebuilt tokens.dat file." 703 | ) else ( 704 | echo tokens.dat file was rebuilt successfully. 705 | ) 706 | 707 | ::======================================================================================================================================== 708 | 709 | :: Rebuild OSPP Tokens 710 | 711 | echo: 712 | echo %line% 713 | echo: 714 | call :_color %Blue% "Rebuilding OSPP Licensing Tokens" 715 | echo: 716 | 717 | sc qc osppsvc %nul% || ( 718 | echo OSPP based Office is not installed 719 | echo Skipping rebuilding OSPP tokens... 720 | goto :repairoffice 721 | ) 722 | 723 | call :scandatospp check 724 | 725 | if not defined token ( 726 | call :_color %Red% "tokens.dat file not found." 727 | ) else ( 728 | echo tokens.dat file: [%token%] 729 | ) 730 | 731 | echo: 732 | echo Stopping osppsvc service... 733 | %psc% Stop-Service osppsvc -force %nul% 734 | 735 | echo: 736 | call :scandatospp delete 737 | call :scandatospp check 738 | 739 | if defined token ( 740 | echo: 741 | call :_color %Red% "Failed to delete .dat files." 742 | echo: 743 | ) 744 | 745 | echo: 746 | echo Starting osppsvc service to generate tokens.dat 747 | %psc% Start-Service osppsvc %nul% 748 | call :scandatospp check 749 | if not defined token ( 750 | %psc% Stop-Service osppsvc -force %nul% 751 | %psc% Start-Service osppsvc %nul% 752 | timeout /t 3 %nul% 753 | ) 754 | 755 | call :scandatospp check 756 | 757 | echo: 758 | if not defined token ( 759 | call :_color %Red% "Failed to rebuilt tokens.dat file." 760 | ) else ( 761 | echo tokens.dat file was rebuilt successfully. 762 | ) 763 | 764 | ::======================================================================================================================================== 765 | 766 | :repairoffice 767 | 768 | echo: 769 | echo %line% 770 | echo: 771 | call :_color %Blue% "Repairing Office Licenses" 772 | echo: 773 | 774 | for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE') do set arch=%%b 775 | 776 | if /i "%arch%"=="ARM64" ( 777 | echo: 778 | echo ARM64 Windows Found. 779 | echo You need to use repair option in Windows settings for Office. 780 | echo: 781 | start ms-settings:appsfeatures 782 | goto :repairend 783 | ) 784 | 785 | if /i "%arch%"=="x86" ( 786 | set arch=X86 787 | ) else ( 788 | set arch=X64 789 | ) 790 | 791 | for %%# in (68 86) do ( 792 | for %%A in (msi14 msi15 msi16 c2r14 c2r15 c2r16) do (set %%A_%%#=&set %%Arepair%%#=) 793 | ) 794 | 795 | set _68=HKLM\SOFTWARE\Microsoft\Office 796 | set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office 797 | 798 | reg query %_68%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_68=Office 14.0 C2R x86/x64" & set "c2r14repair68=") 799 | reg query %_86%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_86=Office 14.0 C2R x86" & set "c2r14repair86=") 800 | 801 | for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi14_86=Office 14.0 MSI x86" & set "msi14repair86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\Office Setup Controller\Setup.exe") 802 | for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi14_68=Office 14.0 MSI x86/x64" & set "msi14repair68=%systemdrive%\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\Setup.exe") 803 | for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi15_86=Office 15.0 MSI x86" & set "msi15repair86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE15\Office Setup Controller\Setup.exe") 804 | for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi15_68=Office 15.0 MSI x86/x64" & set "msi15repair68=%systemdrive%\Program Files\Common Files\microsoft shared\OFFICE15\Office Setup Controller\Setup.exe") 805 | for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi16_86=Office 16.0 MSI x86" & set "msi16repair86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE16\Office Setup Controller\Setup.exe") 806 | for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi16_68=Office 16.0 MSI x86/x64" & set "msi16repair68=%systemdrive%\Program Files\Common Files\Microsoft Shared\OFFICE16\Office Setup Controller\Setup.exe") 807 | 808 | for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (set "c2r15_86=Office 15.0 C2R x86" & set "c2r15repair86=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\integratedoffice.exe") 809 | for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (set "c2r15_68=Office 15.0 C2R x86/x64" & set "c2r15repair68=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\integratedoffice.exe") 810 | for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (set "c2r16_86=Office 16.0 C2R x86" & set "c2r16repair86=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\OfficeClickToRun.exe") 811 | for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (set "c2r16_68=Office 16.0 C2R x86/x64" & set "c2r16repair68=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\OfficeClickToRun.exe") 812 | 813 | set uwp16= 814 | if %winbuild% GEQ 10240 ( 815 | %psc% "Get-AppxPackage -name "Microsoft.Office.Desktop"" | find /i "Office" %nul1% && set uwp16=Office 16.0 UWP 816 | ) 817 | 818 | set /a counter=0 819 | echo Checking installed Office versions... 820 | echo: 821 | 822 | for %%# in ( 823 | "%msi14_68%" 824 | "%msi14_86%" 825 | "%msi15_68%" 826 | "%msi15_86%" 827 | "%msi16_68%" 828 | "%msi16_86%" 829 | "%c2r14_68%" 830 | "%c2r14_86%" 831 | "%c2r15_68%" 832 | "%c2r15_86%" 833 | "%c2r16_68%" 834 | "%c2r16_86%" 835 | "%uwp16%" 836 | ) do ( 837 | if not "%%#"=="""" ( 838 | set insoff=%%# 839 | set insoff=!insoff:"=! 840 | echo [!insoff!] 841 | set /a counter+=1 842 | ) 843 | ) 844 | 845 | if %counter% GTR 1 ( 846 | %eline% 847 | echo Multiple office versions found. 848 | echo It's recommended to install only one version of office. 849 | echo ________________________________________________________________ 850 | echo: 851 | ) 852 | 853 | if %counter% EQU 0 ( 854 | echo: 855 | echo Installed Office is not found. 856 | goto :repairend 857 | echo: 858 | ) else ( 859 | echo: 860 | call :_color %_Yellow% "A Window will popup, in that Window you need to select [Quick] Repair Option..." 861 | call :_color %_Yellow% "Press any key to continue..." 862 | echo: 863 | pause %nul1% 864 | ) 865 | 866 | if defined uwp16 ( 867 | echo: 868 | echo Note: Skipping repair for Office 16.0 UWP. 869 | echo You need to use reset option in Windows settings for it. 870 | echo ________________________________________________________________ 871 | echo: 872 | start ms-settings:appsfeatures 873 | ) 874 | 875 | set c2r14= 876 | if defined c2r14_68 set c2r14=1 877 | if defined c2r14_86 set c2r14=1 878 | 879 | if defined c2r14 ( 880 | echo: 881 | echo Note: Skipping repair for Office 14.0 C2R 882 | echo You need to use Repair option in Windows settings for it. 883 | echo ________________________________________________________________ 884 | echo: 885 | start appwiz.cpl 886 | ) 887 | 888 | if defined msi14_68 if exist "%msi14repair68%" echo Running - "%msi14repair68%" & "%msi14repair68%" 889 | if defined msi14_86 if exist "%msi14repair86%" echo Running - "%msi14repair86%" & "%msi14repair86%" 890 | if defined msi15_68 if exist "%msi15repair68%" echo Running - "%msi15repair68%" & "%msi15repair68%" 891 | if defined msi15_86 if exist "%msi15repair86%" echo Running - "%msi15repair86%" & "%msi15repair86%" 892 | if defined msi16_68 if exist "%msi16repair68%" echo Running - "%msi16repair68%" & "%msi16repair68%" 893 | if defined msi16_86 if exist "%msi16repair86%" echo Running - "%msi16repair86%" & "%msi16repair86%" 894 | if defined c2r15_68 if exist "%c2r15repair68%" echo Running - "%c2r15repair68%" REPAIRUI RERUNMODE & "%c2r15repair68%" REPAIRUI RERUNMODE 895 | if defined c2r15_86 if exist "%c2r15repair86%" echo Running - "%c2r15repair86%" REPAIRUI RERUNMODE & "%c2r15repair86%" REPAIRUI RERUNMODE 896 | if defined c2r16_68 if exist "%c2r16repair68%" echo Running - "%c2r16repair68%" scenario=Repair & "%c2r16repair68%" scenario=Repair 897 | if defined c2r16_86 if exist "%c2r16repair86%" echo Running - "%c2r16repair86%" scenario=Repair & "%c2r16repair86%" scenario=Repair 898 | 899 | :repairend 900 | 901 | echo: 902 | echo %line% 903 | echo: 904 | echo: 905 | call :_color %Green% "Finished" 906 | goto :at_back 907 | 908 | ::======================================================================================================================================== 909 | 910 | :fixwmi 911 | 912 | cls 913 | mode 98, 34 914 | title Fix WMI 915 | 916 | :: https://techcommunity.microsoft.com/t5/ask-the-performance-team/wmi-repository-corruption-or-not/ba-p/375484 917 | 918 | if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" ( 919 | %eline% 920 | echo WMI rebuild is not recommended on Windows Server. Aborting... 921 | goto :at_back 922 | ) 923 | 924 | for %%# in (wmic.exe) do @if "%%~$PATH:#"=="" ( 925 | %eline% 926 | echo wmic.exe file is not found in the system. Aborting... 927 | goto :at_back 928 | ) 929 | 930 | echo: 931 | echo Checking WMI 932 | call :checkwmi 933 | 934 | :: Apply basic fix first and check 935 | 936 | if defined error ( 937 | %psc% Stop-Service Winmgmt -force %nul% 938 | winmgmt /salvagerepository %nul% 939 | call :checkwmi 940 | ) 941 | 942 | if not defined error ( 943 | echo [Working] 944 | echo No need to apply this option. Aborting... 945 | goto :at_back 946 | ) 947 | 948 | call :_color %Red% "[Not Responding]" 949 | 950 | set _corrupt= 951 | sc start Winmgmt %nul% 952 | if %errorlevel% EQU 1060 set _corrupt=1 953 | sc query Winmgmt %nul% || set _corrupt=1 954 | for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type) do if not defined _corrupt (reg query HKLM\SYSTEM\CurrentControlSet\Services\Winmgmt /v %%G %nul% || set _corrupt=1) 955 | 956 | echo: 957 | if defined _corrupt ( 958 | %eline% 959 | echo Winmgmt service is corrupted. Aborting... 960 | goto :at_back 961 | ) 962 | 963 | echo Disabling Winmgmt service 964 | sc config Winmgmt start= disabled %nul% 965 | if %errorlevel% EQU 0 ( 966 | echo [Successful] 967 | ) else ( 968 | call :_color %Red% "[Failed] Aborting..." 969 | sc config Winmgmt start= auto %nul% 970 | goto :at_back 971 | ) 972 | 973 | echo: 974 | echo Stopping Winmgmt service 975 | %psc% Stop-Service Winmgmt -force %nul% 976 | %psc% Stop-Service Winmgmt -force %nul% 977 | %psc% Stop-Service Winmgmt -force %nul% 978 | sc query Winmgmt | find /i "STOPPED" %nul% && ( 979 | echo [Successful] 980 | ) || ( 981 | call :_color %Red% "[Failed]" 982 | echo: 983 | call :_color %Blue% "Its recommended to select [Restart] option and then apply Fix WMI option again." 984 | echo %line% 985 | echo: 986 | choice /C:21 /N /M "> [1] Restart [2] Revert Back Changes :" 987 | if !errorlevel!==1 (sc config Winmgmt start= auto %nul%&goto :at_back) 988 | echo: 989 | echo Restarting... 990 | shutdown -t 5 -r 991 | exit 992 | ) 993 | 994 | echo: 995 | echo Deleting WMI repository 996 | rmdir /s /q "%windir%\System32\wbem\repository\" %nul% 997 | if exist "%windir%\System32\wbem\repository\" ( 998 | call :_color %Red% "[Failed]" 999 | ) else ( 1000 | echo [Successful] 1001 | ) 1002 | 1003 | echo: 1004 | echo Enabling Winmgmt service 1005 | sc config Winmgmt start= auto %nul% 1006 | if %errorlevel% EQU 0 ( 1007 | echo [Successful] 1008 | ) else ( 1009 | call :_color %Red% "[Failed]" 1010 | ) 1011 | 1012 | call :checkwmi 1013 | if not defined error ( 1014 | echo: 1015 | echo Checking WMI 1016 | call :_color %Green% "[Working]" 1017 | goto :at_back 1018 | ) 1019 | 1020 | echo: 1021 | echo Registering .dll's and Compiling .mof's, .mfl's 1022 | call :registerobj %nul% 1023 | 1024 | echo: 1025 | echo Checking WMI 1026 | call :checkwmi 1027 | if defined error ( 1028 | call :_color %Red% "[Not Responding]" 1029 | echo: 1030 | echo Run [Dism RestoreHealth] and [SFC Scannow] options and make sure there are no errors. 1031 | ) else ( 1032 | call :_color %Green% "[Working]" 1033 | ) 1034 | 1035 | goto :at_back 1036 | 1037 | :registerobj 1038 | 1039 | :: https://eskonr.com/2012/01/how-to-fix-wmi-issues-automatically/ 1040 | 1041 | %psc% Stop-Service Winmgmt -force %nul% 1042 | cd /d %systemroot%\system32\wbem\ 1043 | regsvr32 /s %systemroot%\system32\scecli.dll 1044 | regsvr32 /s %systemroot%\system32\userenv.dll 1045 | mofcomp cimwin32.mof 1046 | mofcomp cimwin32.mfl 1047 | mofcomp rsop.mof 1048 | mofcomp rsop.mfl 1049 | for /f %%s in ('dir /b /s *.dll') do regsvr32 /s %%s 1050 | for /f %%s in ('dir /b *.mof') do mofcomp %%s 1051 | for /f %%s in ('dir /b *.mfl') do mofcomp %%s 1052 | 1053 | winmgmt /salvagerepository 1054 | winmgmt /resetrepository 1055 | exit /b 1056 | 1057 | :checkwmi 1058 | 1059 | :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants 1060 | 1061 | set error= 1062 | wmic path Win32_ComputerSystem get CreationClassName /value %nul2% | find /i "computersystem" %nul1% 1063 | if %errorlevel% NEQ 0 (set error=1& exit /b) 1064 | winmgmt /verifyrepository %nul% 1065 | if %errorlevel% NEQ 0 (set error=1& exit /b) 1066 | 1067 | cscript //nologo %windir%\system32\slmgr.vbs /dlv %nul% 1068 | cmd /c exit /b %errorlevel% 1069 | echo "0x%=ExitCode%" | findstr /i "0x800410 0x800440" %nul1% 1070 | if %errorlevel% EQU 0 set error=1 1071 | exit /b 1072 | 1073 | ::======================================================================================================================================== 1074 | 1075 | :at_back 1076 | 1077 | echo: 1078 | echo %line% 1079 | echo: 1080 | call :_color %_Yellow% "Press any key to go back..." 1081 | pause %nul1% 1082 | goto :at_menu 1083 | 1084 | ::======================================================================================================================================== 1085 | 1086 | :at_done 1087 | 1088 | echo: 1089 | echo Press any key to %_exitmsg%... 1090 | pause %nul1% 1091 | exit /b 1092 | 1093 | ::======================================================================================================================================== 1094 | 1095 | :compresslog 1096 | 1097 | :: https://stackoverflow.com/a/46268232 1098 | 1099 | set "ddf="%SystemRoot%\Temp\ddf"" 1100 | %nul% del /q /f %ddf% 1101 | echo/.New Cabinet>%ddf% 1102 | echo/.set Cabinet=ON>>%ddf% 1103 | echo/.set CabinetFileCountThreshold=0;>>%ddf% 1104 | echo/.set Compress=ON>>%ddf% 1105 | echo/.set CompressionType=LZX>>%ddf% 1106 | echo/.set CompressionLevel=7;>>%ddf% 1107 | echo/.set CompressionMemory=21;>>%ddf% 1108 | echo/.set FolderFileCountThreshold=0;>>%ddf% 1109 | echo/.set FolderSizeThreshold=0;>>%ddf% 1110 | echo/.set GenerateInf=OFF>>%ddf% 1111 | echo/.set InfFileName=nul>>%ddf% 1112 | echo/.set MaxCabinetSize=0;>>%ddf% 1113 | echo/.set MaxDiskFileCount=0;>>%ddf% 1114 | echo/.set MaxDiskSize=0;>>%ddf% 1115 | echo/.set MaxErrors=1;>>%ddf% 1116 | echo/.set RptFileName=nul>>%ddf% 1117 | echo/.set UniqueFiles=ON>>%ddf% 1118 | for /f "tokens=* delims=" %%D in ('dir /a:-D/b/s "%SystemRoot%\logs\%1"') do ( 1119 | echo/"%%~fD" /inf=no;>>%ddf% 1120 | ) 1121 | makecab /F %ddf% /D DiskDirectory1="" /D CabinetNameTemplate="!desktop!\AT_Logs\%2_%_time%.cab" 1122 | del /q /f %ddf% 1123 | exit /b 1124 | 1125 | ::======================================================================================================================================== 1126 | 1127 | :: This code checks for invalid registry keys in HKLM\SYSTEM\WPA. This issue may appear even on healthy systems 1128 | 1129 | :wpatest: 1130 | $wpaKey = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64').OpenSubKey("SYSTEM\\WPA") 1131 | $count = $wpaKey.SubKeyCount 1132 | 1133 | $osVersion = [System.Environment]::OSVersion.Version 1134 | $minBuildNumber = 14393 1135 | 1136 | if ($osVersion.Build -ge $minBuildNumber) { 1137 | $subkeyHashTable = @{} 1138 | foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { 1139 | $keyNumber = $subkeyName -replace '.*-', '' 1140 | $subkeyHashTable[$keyNumber] = $true 1141 | } 1142 | for ($i=1; $i -le $count; $i++) { 1143 | if (-not $subkeyHashTable.ContainsKey("$i")) { 1144 | Write-Host "Total Keys $count. Error Found- $i key does not exist" 1145 | $wpaKey.Close() 1146 | exit 1147 | } 1148 | } 1149 | } 1150 | $wpaKey.GetSubKeyNames() | ForEach-Object { 1151 | $subkey = $wpaKey.OpenSubKey($_) 1152 | $p = $subkey.GetValueNames() 1153 | if (($p | Where-Object { $subkey.GetValueKind($_) -eq [Microsoft.Win32.RegistryValueKind]::Binary }).Count -eq 0) { 1154 | Write-Host "Total Keys $count. Error Found- Binary Data is corrupt" 1155 | $wpaKey.Close() 1156 | exit 1157 | } 1158 | } 1159 | $count 1160 | $wpaKey.Close() 1161 | :wpatest: 1162 | 1163 | ::======================================================================================================================================== 1164 | 1165 | :checkperms 1166 | 1167 | set permerror= 1168 | if not exist "%tokenstore%\" set permerror=1 1169 | 1170 | for %%# in ( 1171 | "%tokenstore%" 1172 | "HKLM:\SYSTEM\WPA" 1173 | "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" 1174 | ) do if not defined permerror ( 1175 | %psc% "$acl = Get-Acl '%%#'; if ($acl.Access.Where{ $_.IdentityReference -eq 'NT SERVICE\sppsvc' -and $_.AccessControlType -eq 'Deny' -or $acl.Access.IdentityReference -notcontains 'NT SERVICE\sppsvc'}) {Exit 2}" %nul% 1176 | if !errorlevel!==2 set permerror=1 1177 | ) 1178 | exit /b 1179 | 1180 | ::======================================================================================================================================== 1181 | 1182 | :scandat 1183 | 1184 | set token= 1185 | for %%# in ( 1186 | %Systemdrive%\Windows\System32\spp\store_test\2.0\ 1187 | %Systemdrive%\Windows\System32\spp\store\ 1188 | %Systemdrive%\Windows\System32\spp\store\2.0\ 1189 | %Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\ 1190 | ) do ( 1191 | 1192 | if %1==check ( 1193 | if exist %%#tokens.dat set token=%%#tokens.dat 1194 | ) 1195 | 1196 | if %1==delete ( 1197 | if exist %%# ( 1198 | %nul% dir /a-d /s "%%#*.dat" && ( 1199 | attrib -r -s -h "%%#*.dat" /S 1200 | del /S /F /Q "%%#*.dat" 1201 | ) 1202 | ) 1203 | ) 1204 | ) 1205 | exit /b 1206 | 1207 | :scandatospp 1208 | 1209 | set token= 1210 | for %%# in ( 1211 | %ProgramData%\Microsoft\OfficeSoftwareProtectionPlatform\ 1212 | ) do ( 1213 | 1214 | if %1==check ( 1215 | if exist %%#tokens.dat set token=%%#tokens.dat 1216 | ) 1217 | 1218 | if %1==delete ( 1219 | if exist %%# ( 1220 | %nul% dir /a-d /s "%%#*.dat" && ( 1221 | attrib -r -s -h "%%#*.dat" /S 1222 | del /S /F /Q "%%#*.dat" 1223 | ) 1224 | ) 1225 | ) 1226 | ) 1227 | exit /b 1228 | 1229 | ::======================================================================================================================================== 1230 | 1231 | :regownstart 1232 | 1233 | %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regown\:.*';iex ($f[1]);" 1234 | exit /b 1235 | 1236 | :: Below code takes ownership of a volatile registry key and deletes it 1237 | :: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState 1238 | 1239 | :regown: 1240 | $AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1) 1241 | $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False) 1242 | $TypeBuilder = $ModuleBuilder.DefineType(0) 1243 | 1244 | $TypeBuilder.DefinePInvokeMethod('RtlAdjustPrivilege', 'ntdll.dll', 'Public, Static', 1, [int], @([int], [bool], [bool], [bool].MakeByRefType()), 1, 3) | Out-Null 1245 | $TypeBuilder.CreateType()::RtlAdjustPrivilege(9, $true, $false, [ref]$false) | Out-Null 1246 | 1247 | $SID = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-544') 1248 | $IDN = ($SID.Translate([System.Security.Principal.NTAccount])).Value 1249 | $Admin = New-Object System.Security.Principal.NTAccount($IDN) 1250 | 1251 | $path = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState' 1252 | $key = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64').OpenSubKey($path, 'ReadWriteSubTree', 'takeownership') 1253 | 1254 | $acl = $key.GetAccessControl() 1255 | $acl.SetOwner($Admin) 1256 | $key.SetAccessControl($acl) 1257 | 1258 | $rule = New-Object System.Security.AccessControl.RegistryAccessRule($Admin,"FullControl","Allow") 1259 | $acl.SetAccessRule($rule) 1260 | $key.SetAccessControl($acl) 1261 | :regown: 1262 | 1263 | ::======================================================================================================================================== 1264 | 1265 | :_color 1266 | 1267 | if %_NCS% EQU 1 ( 1268 | echo %esc%[%~1%~2%esc%[0m 1269 | ) else ( 1270 | call :batcol %~1 "%~2" 1271 | ) 1272 | exit /b 1273 | 1274 | :_color2 1275 | 1276 | if %_NCS% EQU 1 ( 1277 | echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m 1278 | ) else ( 1279 | call :batcol %~1 "%~2" %~3 "%~4" 1280 | ) 1281 | exit /b 1282 | 1283 | ::======================================= 1284 | 1285 | :: Colored text with pure batch method 1286 | :: Thanks to @dbenham and @jeb 1287 | :: stackoverflow.com/a/10407642 1288 | 1289 | :batcol 1290 | 1291 | pushd %_coltemp% 1292 | if not exist "'" ("'" set /p "=.") 1293 | setlocal 1294 | set "s=%~2" 1295 | set "t=%~4" 1296 | call :_batcol %1 s %3 t 1297 | del /f /q "'" 1298 | del /f /q "`.txt" 1299 | popd 1300 | exit /b 1301 | 1302 | :_batcol 1303 | 1304 | setlocal EnableDelayedExpansion 1305 | set "s=!%~2!" 1306 | set "t=!%~4!" 1307 | for /f delims^=^ eol^= %%i in ("!s!") do ( 1308 | if "!" equ "" setlocal DisableDelayedExpansion 1309 | >`.txt (echo %%i\..\') 1310 | findstr /a:%~1 /f:`.txt "." 1311 | `.txt (echo %%i\..\') 1318 | findstr /a:%~3 /f:`.txt "." 1319 | 2 | 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

MAS Logo

2 | 3 |

Microsoft Activation Scripts (MAS)

4 | 5 |

A Windows and Office activator using HWID / Ohook / KMS38 / Online KMS activation methods, with a focus on open-source code and fewer antivirus detections.

6 | 7 |

8 | Chat with us without signup 9 | MAS on Reddit 10 | Follow us on X 11 |

12 | 13 |
14 | 15 | ## Download / How to use it? 16 | 17 | ### Method 1 - PowerShell (Recommended) 18 | 19 | - Right-click on the Windows start menu and select PowerShell or Terminal (Not CMD). 20 | - Copy and paste the code below and press enter 21 | ``` 22 | irm https://get.activated.win | iex 23 | ``` 24 | or (deprecated, will be retired on Aug 31 2024, use above instead) 25 | ``` 26 | irm https://massgrave.dev/get | iex 27 | ``` 28 | - You will see the activation options. Follow the on-screen instructions. 29 | - That's all. 30 | 31 | --- 32 | 33 | - On older Windows builds you may need to run the below command before, 34 | `[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12` 35 | - The Powershell method does not work on Windows 7. Use the Method 2 - Traditional instead. 36 | - The URL get.activated.win may be blocked by some DNS services because it is a new domain. 37 | 38 | ### Method 2 - Traditional 39 | 40 | - Download the file under the code button from [GitHub](https://github.com/massgravel/Microsoft-Activation-Scripts) or [Bitbucket](https://bitbucket.org/WindowsAddict/microsoft-activation-scripts) 41 | - Right-click on the downloaded zip file and extract 42 | - In the extracted folder, find the folder named `All-In-One-Version` 43 | - Run the file named `MAS_AIO-CRC32_XXXXXXXX.cmd` 44 | - You will see the activation options, follow the on-screen instructions. 45 | - That's all. 46 | 47 | To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches) 48 | 49 |
50 | 51 | ``` 52 | Latest Version: 2.6 53 | Release date: 20-Apr-2024 54 | ``` 55 | 56 | ### [Troubleshooting / Help](https://massgrave.dev/troubleshoot) 57 | ### [Download Original Windows & Office](https://massgrave.dev/genuine-installation-media) 58 | ### Homepage - [https://massgrave.dev/](https://massgrave.dev/) 59 | 60 | --- 61 | 62 |

Made with Love ❤️

63 | --------------------------------------------------------------------------------