Solved $OEM$


monito1994

New member
Local time
8:54 PM
Posts
9
OS
windows 11 Pro
Dear Community,I am writing to you to request your help.I want to integrate reg files for my customized Windows 10/11 ISOs, but I want them to be installed during the installation, taking into consideration leaving said reg files in the $OEM$ folder. It should be noted that I have a setupcomplete.cmd file with automatic activation but I don't know if it is possible to have more than one setupcomplete.cmd, and if you could please help me to do it.I understand that you can create subfolders but I don't know beyond that.
 
Windows Build/Version
windows 10/11

My Computer

System One

  • OS
    windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    lenovo l490
    CPU
    Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz 2.10 GHz
    Memory
    32 GB
Your thread is marked as Solved. If you still want help mark it as Unsolved.
 

My Computers

System One System Two

  • OS
    Windows 7 HP 64 - Windows 11 Pro - Lubuntu
    Computer type
    PC/Desktop
    Manufacturer/Model
    custom build
    CPU
    i5 6600K - 800MHz to 4400MHz
    Motherboard
    GA-Z170-HD3P
    Memory
    4+4G GSkill DDR4 3000
    Graphics Card(s)
    IG - Intel 530
    Monitor(s) Displays
    Samsung 226BW
    Screen Resolution
    1680x1050
    Hard Drives
    (1) -1 SM951 – 128GB M.2 AHCI PCIe SSD drive for Win 11
    (2) -1 WD SATA 3 - 1T for Data
    (3) -1 WD SATA 3 - 1T for backup
    (4) -1 BX500 SSD - 128G for Windows 7 and Lubuntu
    PSU
    Thermaltake 450W TR2 gold
    Keyboard
    Old and good Chicony mechanical keyboard
    Mouse
    Logitech mX performance - 9 buttons (had to disable some)
    Internet Speed
    500 Mb/s
    Browser
    Firefox 64
  • Operating System
    Windows 7 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Asus Q550LF
    CPU
    i7-4500U 800- 3000MHz
    Motherboard
    Asus Q550LF
    Memory
    (4+4)G DDR3 1600
    Graphics card(s)
    IG intel 4400 + NVIDIA GeForce GT 745M
    Sound Card
    Realtek
    Monitor(s) Displays
    LG Display LP156WF4-SPH1
    Screen Resolution
    1920 x 1080
    Hard Drives
    BX500 120G SSD for Windows and programs
    & 1T HDD for data
    Internet Speed
    350 Mb/s
    Browser
    Firefox 64
Let's break down your question into two parts.

When OOBE is finished, Windows searches for the file %WINDIR%\Setup\Files\SetupComplete.cmd to execute. There's only one version of this file on the installed Windows. If you need to run different versions of the script, you have two options:

1. Use a shared SetupComplete.cmd script for all of the install images. This is the default method used by most users, and the simplest.
Add scripting logic to your batch file, and find which version of Windows is installed, before running different commands. Or run other scripts from SetupComplete.cmd, using the CALL function.​

For example:
Code:
@echo off

setlocal
for /f "tokens=4" %%a in ('wmic os get Caption /value ^| findstr Caption') do set VERSION=%%a

if "%VERSION%"=="Home" (
    reg add C:\path\Home.reg
) else if "%VERSION%"=="Pro" (
    reg add C:\path\Pro.reg
) else (
    call C:\path\other_script.bat
REM Returns here after the other script runs
)

2. Use a private copy of SetupComplete.cmd embedded inside each install image. This method requires the most work, but avoids the scripting logic. If you only have a few images, it's not too bad.
Mount each image that you want to add the script, copy the file to the temporary mount folder, and commit the change.​

Code:
mkdir D:\Mount
Dism /Mount-image /imagefile:\D:\path\ISO\sources\install.wim /Index:1 /MountDir:D:\Mount
mkdir D:\Mount\Windows\Setup\Files
copy SetupComplete.cmd D:\Mount\Windows\Setup\Files
Dism /Unmount-image /MountDir:D:\Mount /Commit


For the actual reg files, you can have Windows Setup copy them to target folders on the installed PC. When Setup finds a \sources\$OEM$ folder on the ISO (or USB drive), it follows these rules:

sources\$OEM$\$1 -> Copied to C:\
sources\$OEM$\$2 -> Copied to D:\
...
sources\$OEM$\$$ -> Copied to C:\Windows
sources\$OEM$\$$\Setup\Files -> Copied to C:\Windows\Setup\Files

sources\$OEM$\$$\Setup\Files\SetupComplete.cmd -> C:\Windows\Setup\Files\SetupComplete.cmd (Option 1 from above)

sources\$OEM$\$1\Install\Home.reg -> C:\Install\Home.reg
sources\$OEM$\$1\Install\Pro.reg -> C:\Install\Pro.reg
 
Last edited:

My Computer

System One

  • OS
    Windows 7

My Computer

System One

  • OS
    windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    lenovo l490
    CPU
    Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz 2.10 GHz
    Memory
    32 GB
Vamos a dividir tu pregunta en dos partes.

Cuando finaliza la configuración rápida, Windows busca el archivo %WINDIR%\Setup\Files\SetupComplete.cmd para ejecutarlo. Solo hay una versión de este archivo en el Windows instalado. Si necesita ejecutar diferentes versiones del script, tiene dos opciones:

1. Utilice un script de SetupComplete.cmd compartido para todas las imágenes de instalación. Este es el método predeterminado utilizado por la mayoría de los usuarios y el más simple.
Agregue lógica de scripting al archivo por lotes y busque qué versión de Windows está instalada antes de ejecutar diferentes comandos. O ejecute otros scripts desde SetupComplete.cmd, utilizando la función CALL.​

Por ejemplo:
[CÓDIGO]
@echo desactivado

setlocal
for /f "tokens=4" %%a in ('wmic os get Caption /value ^| findstr Caption') do set VERSION=%%a

if "%VERSION%"=="Inicio" (
reg add C:\path\Home.reg
) else if "%VERSION%"=="Pro" (
reg add C:\path\Pro.reg
) else (
llame a C:\path\other_script.bat
REM Regresa aquí después de que se ejecute el otro script
)
[/CÓDIGO]

2. Utilice una copia privada de SetupComplete.cmd incrustada dentro de cada imagen de instalación. Este método requiere la mayor cantidad de trabajo, pero evita la lógica de scripting. Si solo tienes unas pocas imágenes, no está tan mal.
Monte cada imagen a la que desee agregar el script, copie el archivo en la carpeta de montaje temporal y confirme el cambio.​

[CÓDIGO]
mkdir D:\Montar
Dism /Mount-image /imagefile:\D:\path\ISO\sources\install.wim /Index:1 /MountDir:D:\Mount
mkdir D:\Mount\Windows\Setup\Files
copiar SetupComplete.cmd D:\Mount\Windows\Setup\Files
Dism /Unmount-image /MountDir:D:\Mount /Commit
[/CÓDIGO]


Para los archivos de registro reales, puede hacer que el programa de instalación de Windows los copie en las carpetas de destino de la PC instalada. Cuando el programa de instalación encuentra una carpeta \sources\$OEM$ en la ISO (o unidad USB), sigue estas reglas:

sources\$OEM$\$1 -> Copiado a C:\
sources\$OEM$\$2 -> Copiado a D:\
...
sources\$OEM$\$$ -> Copiado a C:\Windows
sources\$OEM$\$$\Setup\Files -> copiado en C:\Windows\Setup\Files

sources\$OEM$\$$\Setup\Files\SetupComplete.cmd -> C:\Windows\Setup\Files\SetupComplete.cmd (Opción 1 desde arriba)

sources\$OEM$\$1\Install\Home.reg -> C:\Install\Home.reg
sources\$OEM$\$1\Install\Pro.reg -> C:\Install\Pro.reg

Estimado @garlin ,

I appreciate your time and help. But if it were the case to leave them in C:\Windows\Setup\Files, how can they be executed from the autoextend file and then automatically deleted?

I have tried to run the reg in the specialize phase, although it did not work for me, I am thinking of trying it in the auditUser phase

I look forward to your prompt response
 

My Computer

System One

  • OS
    windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    lenovo l490
    CPU
    Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz 2.10 GHz
    Memory
    32 GB
$OEM$ folders are copied by WinPE Setup, right after the Windows image is applied to the target drive and before the first reboot. They are immediately available to audit & specialize passes.

Windows will not clean up any files copied by the $OEM$ folders. SetupComplete should remove those folders and files, if that's necessary.
Code:
rd /q /s "C:\Install"
rd /q /s "%WINDIR%\Setup\Files"
del /q /f "%0"

HKLM keys can be imported by SetupComplete.cmd.
HKCU keys cannot be updated this way, because HKCU is an alias for CURRENT_USER and SetupComplete is running as SYSTEM (not as you).

Some keys cannot be applied too early during installation, if Windows hasn't yet created the original reg values during first-time setup.
Some keys cannot be changed because they're protected by TRUSTED_INSTALLER rights.

If you have a specific examples, it's easier to make a comment.
 

My Computer

System One

  • OS
    Windows 7

My Computers

System One System Two

  • OS
    Windows 7 HP 64 - Windows 11 Pro - Lubuntu
    Computer type
    PC/Desktop
    Manufacturer/Model
    custom build
    CPU
    i5 6600K - 800MHz to 4400MHz
    Motherboard
    GA-Z170-HD3P
    Memory
    4+4G GSkill DDR4 3000
    Graphics Card(s)
    IG - Intel 530
    Monitor(s) Displays
    Samsung 226BW
    Screen Resolution
    1680x1050
    Hard Drives
    (1) -1 SM951 – 128GB M.2 AHCI PCIe SSD drive for Win 11
    (2) -1 WD SATA 3 - 1T for Data
    (3) -1 WD SATA 3 - 1T for backup
    (4) -1 BX500 SSD - 128G for Windows 7 and Lubuntu
    PSU
    Thermaltake 450W TR2 gold
    Keyboard
    Old and good Chicony mechanical keyboard
    Mouse
    Logitech mX performance - 9 buttons (had to disable some)
    Internet Speed
    500 Mb/s
    Browser
    Firefox 64
  • Operating System
    Windows 7 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Asus Q550LF
    CPU
    i7-4500U 800- 3000MHz
    Motherboard
    Asus Q550LF
    Memory
    (4+4)G DDR3 1600
    Graphics card(s)
    IG intel 4400 + NVIDIA GeForce GT 745M
    Sound Card
    Realtek
    Monitor(s) Displays
    LG Display LP156WF4-SPH1
    Screen Resolution
    1920 x 1080
    Hard Drives
    BX500 120G SSD for Windows and programs
    & 1T HDD for data
    Internet Speed
    350 Mb/s
    Browser
    Firefox 64
$OEM$ folders are copied by WinPE Setup, right after the Windows image is applied to the target drive and before the first reboot. They are immediately available to audit & specialize passes.

Windows will not clean up any files copied by the $OEM$ folders. SetupComplete should remove those folders and files, if that's necessary.
Code:
rd /q /s "C:\Install"
rd /q /s "%WINDIR%\Setup\Files"
del /q /f "%0"

HKLM keys can be imported by SetupComplete.cmd.
HKCU keys cannot be updated this way, because HKCU is an alias for CURRENT_USER and SetupComplete is running as SYSTEM (not as you).

Some keys cannot be applied too early during installation, if Windows hasn't yet created the original reg values during first-time setup.
Some keys cannot be changed because they're protected by TRUSTED_INSTALLER rights.

If you have a specific examples, it's easier to make a comment.
Estimado @garlin ,

Dear @garlin,

Sorry for the delay. The logs I use for my isos are like this

Windows Registry Editor Version 5.00


[HKEY_CLASSES_ROOT\Directory\Shell\SFC]
"Icon"="WmiPrvSE.exe"
"MUIVerb"="Scan"
"Position"="Down"
"Extended"=-
"Subcommands"=""

[HKEY_CLASSES_ROOT\Drive\Shell\SFC]
"Icon"="WmiPrvSE.exe"
"MUIVerb"="Scan"
"Position"="Down"
"Extended"=-
"Subcommands"=""

[HKEY_CLASSES_ROOT\Directory\shell\SFC\shell\001menu]
"HasLUAShield"=""
"MUIVerb"="Execute SFC Folder"

[HKEY_CLASSES_ROOT\Drive\shell\SFC\shell\002menu]
"HasLUAShield"=""
"MUIVerb"="Execute SFC unit"

[HKEY_CLASSES_ROOT\Directory\shell\SFC\shell\001menu\command]
@="PowerShell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/s,/k, echo Scanning Folder: %1 && sfc /scannow' -Verb runAs\""

[HKEY_CLASSES_ROOT\Drive\shell\SFC\shell\002menu\command]
@="PowerShell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/s,/k, echo Scanning Unit: %1 && sfc /scannow' -Verb runAs\""

Since the other registry that you mention above, you add them from an autoextend.xml file

But it would still be ideal to add them from a setupcomplete.cmd file, since adding them manually 1 x 1 in the autoextend file would create a very extensive and tedious file for me to later change or modify if I needed it.
 

My Computer

System One

  • OS
    windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    lenovo l490
    CPU
    Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz 2.10 GHz
    Memory
    32 GB

My Computer

System One

  • OS
    windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    lenovo l490
    CPU
    Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz 2.10 GHz
    Memory
    32 GB
No, it's not. Go to the first post in this thread, and fnd the Unsolved button near the top, and click that. If you succeed, the green check mark on the thread title in the forum should disappear.

Clipboard_01.jpg
 

My Computers

System One System Two

  • OS
    11 Pro 24H2 26100.1586
    Computer type
    PC/Desktop
    Manufacturer/Model
    Lenovo ThinkCentre M920S SFF
    CPU
    i7-9700 @ 3.00GHz
    Motherboard
    Lenovo 3132
    Memory
    32GBDDR4 @ 2666MHz
    Graphics Card(s)
    Intel HD 630 Graphics onboard
    Sound Card
    Realtek HD Audio
    Monitor(s) Displays
    LG E2442
    Screen Resolution
    1920x1080
    Hard Drives
    1 x Samsung 970 EVO PLUS 500GB NVMe SSD, 1 x WD_BLACK SN770
    250GB NVMe SSD (OS and programs), 1 x WD_BLACK SN770
    500GB NVMe SSD (Data)
    Case
    Lenovo SFF
    Keyboard
    Cherry Stream TKL JK-8600US-2 Wired
    Mouse
    LogiTech M510 wireless
    Internet Speed
    Fast (for fixed wireless!)
    Browser
    Chrome, sometimes Firefox
    Antivirus
    Malwarebytes Premium & Defender (working together beautifully!)
  • Operating System
    11 Pro 24H2 26100.1586
    Computer type
    PC/Desktop
    Manufacturer/Model
    Lenovo ThinkCentre M920S SFF
    CPU
    i5-8400 @ 2.80GHz
    Motherboard
    Lenovo 3132
    Memory
    32GB DDR4 @ 2600MHz
    Graphics card(s)
    Intel HD 630 Graphics onboard
    Sound Card
    Realtek High Definition Audio onboard
    Monitor(s) Displays
    LG FULL HD (1920x1080@59Hz)
    Screen Resolution
    1920 x 1080
    Hard Drives
    1 x Samsung 970 EVO PLUS NVMe; 1 x Samsung 980 NVMe SSD
    Case
    Lenovo Think Centre SFF
    Mouse
    LogiTech M510 wireless
    Keyboard
    Cherry Stream TKL JK-8600US-2 Wired
    Internet Speed
    Fast (for fixed wireless!)
    Browser
    Chrome
    Antivirus
    Malwarebytes Premium and MS Defender, beautiful together
If you're importing a single .reg file, you can use either SetupComplete.cmd or the autounattend file to run "reg import".

The major difference is SetupComplete is always skipped on a PC with an OEM license found in BIOS. For example, any PC from Dell, HP, Lenovo, ASUS, etc. which has pre-installed Windows. Then you must integrate the reg file into the install image, or use the unattend file.

The free edition of NTLite allows you to load an install image, integrate the .reg file, and save the updated image so you no longer need to have a separate command. This requires no knowledge of scripting, or editing the unattended file. You could perform the same steps by DISM mounting an image, loading the image' Registry hives, and merging your changes. Then unloading the hive, and DISM commit the updated image.
 

My Computer

System One

  • OS
    Windows 7
Si va a importar un único archivo .reg, puede usar SetupComplete.cmd o el archivo de desatendida automática para ejecutar "reg import".

La principal diferencia es que SetupComplete siempre se omite en una PC con una licencia OEM que se encuentra en el BIOS. Por ejemplo, cualquier PC de Dell, HP, Lenovo, ASUS, etcétera. que tenga Windows preinstalado. A continuación, debe integrar el archivo reg en la imagen de instalación o utilizar el archivo desatendido.

La edición gratuita de NTLite le permite cargar una imagen de instalación, integrar el archivo .reg y guardar la imagen actualizada para que ya no necesite tener un comando separado. Esto no requiere conocimientos de secuencias de comandos ni de edición del archivo desatendido. Puede realizar los mismos pasos montando DISM una imagen, cargando los subárboles del Registro de la imagen y combinando los cambios. A continuación, descargue el subárbol y DISM confirme la imagen actualizada. Coche

Estimados @garlin
Gracias por su respuesta.

Pero si fuera el caso en un archivo de respuesta automática, en qué fase se agregaría ese archivo, teniendo en cuenta que estaría en la carpeta $OEM$. Imagen adjunta.

1721090045152.png
 

My Computer

System One

  • OS
    windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    lenovo l490
    CPU
    Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz 2.10 GHz
    Memory
    32 GB
1. Add two new RunSynchronous commands in the "4 specialize" pass:
Code:
reg import C:\Install\SFC_menu.reg
Code:
cmd /c rd /q /s "C:\Install"

2. Use Rufus or another tool to install your ISO to an USB drive.

3. Create the $OEM$ subfolder on the USB drive. WSIM doesn't create folders, you have to perform this step by yourself.
Code:
mkdir E:\sources\$OEM$\$1\Install

4. Copy your SFC_menu.reg file to this folder.
 

My Computer

System One

  • OS
    Windows 7
1. Add two new RunSynchronous commands in the "4 specialize" pass:
Code:
reg import C:\Install\SFC_menu.reg
Code:
cmd /c rd /q /s "C:\Install"

2. Use Rufus or another tool to install your ISO to an USB drive.

3. Create the $OEM$ subfolder on the USB drive. WSIM doesn't create folders, you have to perform this step by yourself.
Code:
mkdir E:\sources\$OEM$\$1\Install

4. Copy your SFC_menu.reg file to this folder.
Estimado @garlin ,

I appreciate your knowledge. It worked for me without problems.

Query, does this also work for script? And will they also be executed or is it advisable to do so in the OOBE phase?

I look forward to your prompt response.

Greetings,
 

My Computer

System One

  • OS
    windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    lenovo l490
    CPU
    Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz 2.10 GHz
    Memory
    32 GB
If you want to run any script, the RunSynchronous command is:
Code:
cmd /c C:\path\to\script.bat
powershell -noprofile -execution-policy bypass -f C:\path\to\script.ps1
 

My Computer

System One

  • OS
    Windows 7
Estimado @garlin,

Dear,

I have a question, you know that I have the install.wim in dark mode for both Windows and applications and also in the autoresponder file, but for a strange reason when I start the desktop it shows me in light and when I open explorer I It appears dark inside but for it to update to the dark color completely, I have to restart it from the task manager. I did it from a script but it doesn't run or something happens, if you can help me. I attach the command by which you execute the script.

cmd.exe /c powershell.exe -ExecutionPolicy Bypass -Command "Start-Process cmd.exe -ArgumentList '/c call C:\explorer.bat' -Verb RunAs -WindowStyle Hidden"

and I also attach the script as such:

@echo off

cmd.exe /c taskkill /f /im explorer.exe && start explorer.exe
 

My Computer

System One

  • OS
    windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    lenovo l490
    CPU
    Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz 2.10 GHz
    Memory
    32 GB
Estimados @garlin,

Agradezco su apoyo, ahora pude resolver el problema que tenía con el explorador jeje.

Que tengáis un buen día todos.
 

My Computer

System One

  • OS
    windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    lenovo l490
    CPU
    Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz 2.10 GHz
    Memory
    32 GB
Back
Top Bottom