How to Use Extract_OEM_Folder.cmd to Create a $OEM$ Activation Folder

Extract_OEM_Folder.cmd is a batch script in the Microsoft Activation Scripts (MAS) repository that automates the creation of a $OEM$ folder on your Desktop, embedding selected activation methods (HWID, Ohook, TSforge, or Online KMS) to run automatically during Windows Setup.

The Extract_OEM_Folder.cmd utility from massgravel/Microsoft-Activation-Scripts eliminates manual post-install activation by preparing a self-contained directory that Windows Setup executes automatically. This script validates your environment, presents an interactive menu of activation options, and generates the proper folder hierarchy required for unattended installations.

What Extract_OEM_Folder.cmd Does

Extract_OEM_Folder.cmd serves as the entry-point batch script that constructs a ready-to-use $OEM$ folder on the current user’s Desktop. Located at MAS/Separate-Files-Version/Extract_OEM_Folder.cmd, the script performs nine high-level operations to ensure reliable deployment.

First, the script executes environment preparation via the :dk_setvar section, forcing a 64-bit process, sanitizing the PATH variable, disabling QuickEdit mode, and selecting the proper console host. It then conducts system compatibility checks to verify the Null driver, Windows build number, PowerShell language mode, and .NET availability, while ensuring it is not running from a temporary or extracted archive.

If administrator rights are absent, the script automatically re-launches with elevated privileges. Upon passing validation, it resolves the Desktop path via registry or PowerShell fallback, checks for existing $OEM$ folders to prevent overwrites, and validates that all four activation scripts exist in the Activators sub-folder.

The :Menu label (lines 30-56) presents an interactive interface allowing you to select which activation engines to embed. Finally, the script copies the chosen activators into "$Desktop\$OEM$\$$\Setup\Scripts" and generates a SetupComplete.cmd file using the PowerShell export function (lines 803-808), which handles binary-safe extraction without LF/CRLF corruption. Error handling is centralized at the :errorfound, :done, and :done2 labels (lines 111-135 and 176-210).

Prerequisites and Environment Validation

Before generating the $OEM$ folder, Extract_OEM_Folder.cmd enforces strict compatibility checks to ensure reliable execution across x86, x64, ARM64, and ARM32 architectures.

The script validates the following conditions:

  • Process architecture – Forces 64-bit execution and establishes a reliable PATH environment
  • System integrity – Verifies the Null driver, Windows build compatibility, and that the script is not executing from a temporary archive location
  • PowerShell environment – Checks PowerShell language mode and .NET availability
  • Administrative rights – Detects missing elevation and automatically re-launches with administrator privileges

You can optionally skip the QuickEdit disable step by appending the -qedit flag, which is useful when running inside the new Windows Terminal:

Extract_OEM_Folder.cmd -qedit

Running the Script and Selecting Activation Methods

To create your $OEM$ folder, download Extract_OEM_Folder.cmd from the MAS/Separate-Files-Version/ directory in the repository. Open an elevated Command Prompt and execute:

Extract_OEM_Folder.cmd

The script displays an interactive menu at the :Menu section offering the following options:

Choice Activation Method Placed in $OEM$
1 HWID (Windows digital license)
2 Ohook (Office activation)
3 TSforge (Windows/ESU/Office)
4 Online KMS (Windows/Office)
5 HWID + Ohook combination
6 TSforge + Ohook combination
7 Online KMS + Ohook combination
R Open the README documentation
0 Exit without creating the folder

After selection, the script copies the relevant files from MAS/Separate-Files-Version/Activators/—including HWID_Activation.cmd, Ohook_Activation_AIO.cmd, TSforge_Activation.cmd, or Online_KMS_Activation.cmd—into the destination directory.

Generated Folder Structure and SetupComplete.cmd

Upon successful execution, Extract_OEM_Folder.cmd creates the following hierarchy on your Desktop:


%USERPROFILE%\Desktop\$OEM$\$$\Setup\Scripts

The directory contains your selected activation scripts plus a SetupComplete.cmd file generated by the script’s PowerShell export function. This file serves as the entry point that Windows Setup automatically executes during the $OEM$ phase of installation.

The script ensures binary-safe writing of SetupComplete.cmd using PowerShell’s ReadAllText split logic, preventing corruption of command-line syntax. You can inspect this file to verify the exact activation commands that will run during Windows Setup.

Summary

  • Extract_OEM_Folder.cmd is a self-checking batch utility in MAS/Separate-Files-Version/ that automates $OEM$ folder creation.
  • The script enforces 64-bit execution, validates system prerequisites, and requires administrator elevation.
  • Users select activation methods via an interactive menu (lines 30-56) to embed HWID, Ohook, TSforge, or Online KMS engines.
  • The output folder structure follows the Windows Setup convention: $OEM$\$$\Setup\Scripts\SetupComplete.cmd.
  • Activation scripts are copied from the Activators sub-folder and configured to run automatically during Windows installation.

Frequently Asked Questions

What is the purpose of the $OEM$ folder in Windows Setup?

The $OEM$ folder is a special directory that Windows Setup scans during installation. When placed in the root of the installation source, Windows automatically executes SetupComplete.cmd from $$\Setup\Scripts after the setup phase completes, allowing unattended execution of activation scripts without manual user intervention.

Which activation methods can I embed using Extract_OEM_Folder.cmd?

You can embed four activation methods: HWID for Windows digital licenses, Ohook for Office, TSforge for Windows/ESU/Office, and Online KMS for Windows/Office. The script allows selecting individual methods or combinations (HWID + Ohook, TSforge + Ohook, or Online KMS + Ohook) through menu options 1-7.

Where does Extract_OEM_Folder.cmd place the generated files?

The script resolves the Desktop path via registry query or PowerShell fallback and creates the folder at %USERPROFILE%\Desktop\$OEM$\$$\Setup\Scripts. If a $OEM$ folder already exists on the Desktop, the script aborts to prevent accidental overwrites.

Can I run Extract_OEM_Folder.cmd on ARM-based Windows devices?

Yes. The script explicitly supports x86, x64, ARM64, and ARM32 architectures through its environment bootstrap (:dk_setvar section), which forces proper 64-bit process execution and sanitizes system paths regardless of the underlying hardware platform.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →