TUTORIAL: Create perfect Windows Post-Setup using OOBE.cmd

I am also having an issue with OOBS.cmd not executing.
I have used NTLITE to make an unnattended setup... That works. But OOBE.cmd just isnt seen by windows setup. I am not sure why. \
What information would i be able to provide that would assist with a solution please?
 
Good Morning,
I have tried integrating this key but as yet nothing is launching it. I have no idea why...
Another post further up suggested that the key may not even work on more recent editions of windows 10. Any truth to this?

EDIT: More accurately, the order by which RunOnceEX and RunOnce reg keys are executed may prevent OOBE.cmd even launching in the first place?
 
Last edited:
RunOnce key is launched during setup, after first reboot. Then RunOnceEx key from OOBE.cmd are writen into registry.
After second reboot is launched OOBE, then RunOnceEx key.

I have another idea why it doesn't work for you.... Are you sure you have required Internet Explorer components?

These files must be present in setup media
Code:
        <ProtectedFiles>
            <File>*SysWoW64\*\iernonce.dll.mui</File>
            <File>*SysWoW64\iernonce.dll</File>
            <File>*SysWoW64\IEAdvpack.dll</File>
            <File>*System32\*\iernonce.dll.mui</File>
            <File>*System32\iernonce.dll</File>
            <File>*System32\IEAdvpack.dll</File>
        </ProtectedFiles>

And what is your Windows version where it doesn't work?
 
Windows Version is Win 10 Pro 2009 (OEM BIOS Key). I havent removed Internet explorer so... Protected files shouldnt matter? I will protect them anyway. Anything else i can do also?
 
George King Could it be a problem in the future, that MS will remove IE completely from Windows? Even the IE-based files you have listed in "protected files" could possible not found in the future because MS removed them.
 
George King Could it be a problem in the future, that MS will remove IE completely from Windows? Even the IE-based files you have listed in "protected files" could possible not found in the future because MS removed them.

Don't worry, I have solution for this too :) POWIS - Powerfull Windows Setup, new script tool to make it easy for everyone is really close to release :)

EDIT: Wolfsrabe POWIS is released!
 
Last edited:
George King, when Windows 11 release later this year, have you thought about making a similar guide for the next Windows operating system?
 
Last edited:
eskebey123

Dude......... enough already. I amongst others have pointed you in the direction you need to go about what you want to do. I don't think hijacking a thread is going to help you. George King has taken the time to do an extremely detailed guide.

YES it can be used to do windows 10 pro x64.
 

This tutorial helps you to create perfect post setup for Windows 7 - 10 setup media


What you can easily install using this tutorial?
1) Microsoft Office
2) Windows or Office updates (MSU / CAB / MSP)
3) Your own applications with predefined switch
4) Apply registry tweaks
5) Certificates CER files
6) Custom scripts - PS1 / CMD / BAT

Every installation steps are run before user logon after OOBE, this mean User Account is already created so all applications and registry tweaks should be installed without problem

We are going to use RunOnceEx method as its most comfortable and suitable way because it is inbox Windows component. RunOnceEx is really old but still working method as part of iernonce.dll + iernonce.dll.mui + IEAdvpack.dll (This file exist from Internet Explorer 9+, so doesn't exist in non updated Windows 7). So this mean you need to have Internet Explorer component in your Windows install.wim / install.esd.

If you want to remove Internet Explorer, you can still use this method!
Just protect these files 3 (6) files in components section in NTLite, you don't need to do it manually, just download and use attached preset RunOnceEx_Protector.xml

View attachment 4183

Lets start with preparing needed folder structure on your setup media

View attachment 3941

You also need Scripts folder inside sources\$OEM$\$$\Setup\Scripts - this folder is needed to call OOBE.cmd as this script is natively called by Windows Setup in all situations not like SetupComplete.cmd and OEM key "problem"

Save text bellow as OOBE.cmd into Scripts folder you created in previous step.
Code:
@echo off
TITLE Setting-up RunOnceEx
CLS

IF EXIST "%WINDIR%\SysWOW64" (
    SET ARCH=x64
) ElSE (
    SET ARCH=x86
)

SET FINTEXT="Windows Post-Setup"
SET CERTEXT="Installing certificates"
SET SCRIPTTEXT="Executing scripts"
SET OFFTEXT="Installing Microsoft Office"
SET MSITEXT="Installing MSI packages"
SET ACTTEXT="Activating products"
SET UPDTEXT="Installing updates"
SET SILTEXT="Installing applications"
SET TWKTEXT="Applying personal settings"
set DRVCLNTEXT="Removing unused drivers"
SET RBTTEXT="Reboot"

FOR %%I IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%I:\sources\install.esd SET DRIVE=%%I:
IF "%DRIVE%" == "" FOR %%I IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%I:\sources\install.wim SET DRIVE=%%I:
IF "%DRIVE%" == "" FOR %%I IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%I:\sources\install.swm SET DRIVE=%%I:

SET ROE=HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx

IF EXIST "%WINDIR%\System32\iernonce.dll" (

    REG ADD %ROE% /v Title /d %FINTEXT% /f
    REG ADD %ROE% /v Flags /t REG_DWORD /d "00000024" /f


    REM From Windows 8 up kill explorer.exe
    IF NOT EXIST "%WINDIR%\Servicing\Version\6.1.*" (
        REG ADD %ROE%\000 /ve /d " " /f
        REG ADD %ROE%\000 /v "KillExplorer" /d "%WINDIR%\System32\cmd.exe /c \"start /min /wait %WINDIR%\setup\scripts\Watcher.cmd\"" /f
    )


    REM Install certificates into My / Root / CA store
    IF EXIST "%DRIVE%\setup\*.cer" (
        REG ADD %ROE%\001 /ve /d %CERTEXT% /f
        FOR %%U IN ("%DRIVE%\setup\*.cer") DO (
            REG ADD %ROE%\001 /v "%%~nU_TrustedPublisher" /d "%WINDIR%\System32\certutil.exe -addstore TrustedPublisher %%U" /f
            REG ADD %ROE%\001 /v "%%~nU_My" /d "%WINDIR%\System32\certutil.exe -addstore My %%U" /f
            REG ADD %ROE%\001 /v "%%~nU_CA" /d "%WINDIR%\System32\certutil.exe -addstore CA %%U" /f
            REG ADD %ROE%\001 /v "%%~nU_Root" /d "%WINDIR%\System32\certutil.exe -addstore Root %%U" /f
        )
    )


    REM Auto-install Microsoft Office 2008 - 2016
    IF EXIST "%DRIVE%\office\%ARCH%\setup.exe" (
        REG ADD %ROE%\002 /ve /d %OFFTEXT% /f
        REG ADD %ROE%\002 /v "MSO" /d "%DRIVE%\office\%ARCH%\setup.exe" /f
    ) ELSE IF EXIST "%DRIVE%\office\All\setup.exe" (
        REG ADD %ROE%\002 /ve /d %OFFTEXT% /f
        REG ADD %ROE%\002 /v "MSO" /d "%DRIVE%\office\All\setup.exe" /f
    )


    REM Auto-install Microsoft Office 2019 / 365
    IF EXIST "%DRIVE%\office\YAOCTRI_Installer.cmd" (
        REG ADD %ROE%\002 /ve /d %OFFTEXT% /f
        REG ADD %ROE%\002 /v "MSO" /d "%DRIVE%\office\YAOCTRI_Installer.cmd" /f
    )
    IF EXIST "%DRIVE%\office\YAOCTRIR_Installer.cmd" (
        REG ADD %ROE%\002 /ve /d %OFFTEXT% /f
        REG ADD %ROE%\002 /v "MSO" /d "%DRIVE%\office\YAOCTRIR_Installer.cmd" /f
    )


    REM Auto-install %ARCH% depend MSI packages
    IF EXIST "%DRIVE%\setup\*-%ARCH%.msi" (
        REG ADD %ROE%\003 /ve /d %MSITEXT% /f

        FOR %%C IN ("%DRIVE%\setup\*-%ARCH%.msi") DO (
            REM Get Installer
            FOR /F "tokens=1 delims=-" %%G IN ("%%~nC") DO (
                REM Get Switch
                if exist "%DRIVE%\setup\%%G.txt" (
                    for /F "usebackq tokens=*" %%A in ("%DRIVE%\setup\%%G.txt") do (
                        REG ADD %ROE%\003 /v "%%~nC" /d "%%C %%A" /f
                    )
                ) else (
                    REG ADD %ROE%\003 /v "%%~nC" /d "msiexec /i %%C /quiet /norestart" /f
                )
            )
        )
    )


    REM Auto-install %ARCH% independent MSI packages
    IF EXIST "%DRIVE%\setup\*-all.msi" (
        REG ADD %ROE%\003 /ve /d %MSITEXT% /f

        FOR %%C IN ("%DRIVE%\setup\*-all.msi") DO (
            REM Get Installer
            FOR /F "tokens=1 delims=-" %%G IN ("%%~nC") DO (
                REM Get Switch
                if exist "%DRIVE%\setup\%%G.txt" (
                    for /F "usebackq tokens=*" %%A in ("%DRIVE%\setup\%%G.txt") do (
                        REG ADD %ROE%\003 /v "%%~nC" /d "%%C %%A" /f
                    )
                ) else (
                    REG ADD %ROE%\003 /v "%%~nC" /d "msiexec /i %%C /quiet /norestart" /f
                )
            )
        )
    )


    REM Windows + Office activation
    IF EXIST "%DRIVE%\support\Activate.cmd" (
        REG ADD %ROE%\004 /ve /d %ACTTEXT% /f
        REG ADD %ROE%\004 /v "Activation" /d "%WINDIR%\System32\cmd.exe /c \"start /min /wait %DRIVE%\support\Activate.cmd\"" /f
    )


    REM Install MSU / CAB / MSP Packages from %DRIVE%\updates
    REG ADD %ROE%\005 /ve /d %UPDTEXT% /f
    FOR %%U IN ("%DRIVE%\updates\*%ARCH%*.msu") DO REG ADD %ROE%\005 /v "%%~nU" /d "dism /Online /Add-Package /PackagePath:%%U /quiet /norestart" /f
    FOR %%U IN ("%DRIVE%\updates\*%ARCH%*.cab") DO REG ADD %ROE%\005 /v "%%~nU" /d "dism /Online /Add-Package /PackagePath:%%U /quiet /norestart" /f
    FOR %%U IN ("%DRIVE%\updates\*%ARCH%*.msp") DO REG ADD %ROE%\005 /v "%%~nU" /d "msiexec /i %%U /quiet /norestart" /f


    REM Auto-install %ARCH% depend software with predefined silent switch
    IF EXIST "%DRIVE%\setup\*-%ARCH%.exe" (
        REG ADD %ROE%\006 /ve /d %SILTEXT% /f

        FOR %%C IN ("%DRIVE%\setup\*-%ARCH%.exe") DO (
            REM Get Installer
            FOR /F "tokens=1 delims=-" %%G IN ("%%~nC") DO (
                REM Get Switch
                if exist "%DRIVE%\setup\%%G.txt" (
                    for /F "usebackq tokens=*" %%A in ("%DRIVE%\setup\%%G.txt") do (
                        REG ADD %ROE%\006 /v "%%~nC" /d "%%C %%A" /f
                    )
                )
            )
        )
    )

    REM Auto-install %ARCH% independent software with predefined silent switch
    IF EXIST "%DRIVE%\setup\*-all.exe" (
        REG ADD %ROE%\006 /ve /d %SILTEXT% /f

        FOR %%C IN ("%DRIVE%\setup\*-all.exe") DO (
            REM Get Installer
            FOR /F "tokens=1 delims=-" %%G IN ("%%~nC") DO (
                REM Get Switch
                if exist "%DRIVE%\setup\%%G.txt" (
                    for /F "usebackq tokens=*" %%A in ("%DRIVE%\setup\%%G.txt") do (
                        REG ADD %ROE%\006 /v "%%~nC" /d "%%C %%A" /f
                    )
                )
            )
        )
    )


    REM Apply REG Tweaks from %DRIVE%\setup
    IF EXIST "%DRIVE%\setup\*.reg" (
        REG ADD %ROE%\007 /ve /d %TWKTEXT% /f
        FOR %%U IN ("%DRIVE%\setup\*.reg") DO REG ADD %ROE%\007 /v "%%~nU" /d "regedit /s %%U" /f
    )


    REM Remove unused drivers from DriverStore
    IF EXIST "%WINDIR%\setup\scripts\CleanDriverStore.cmd" (
        REG ADD %ROE%\008 /ve /d %DRVCLNTEXT% /f
        REG ADD %ROE%\008 /v "Driver CleanUp" /d "%WINDIR%\System32\cmd.exe /c \"start /min /wait %WINDIR%\setup\scripts\CleanDriverStore.cmd\"" /f
    )


    REM Custom PS1 / CMD / BAT scripts execution
    REM PS1
    FOR %%C IN ("%DRIVE%\setup\*.ps1") DO (
        REG ADD %ROE%\009 /ve /d %SCRIPTTEXT% /f
        REG ADD %ROE%\009 /v "%%C" /d "%WINDIR%\System32\cmd.exe /min /c \"start /wait powershell -NoLogo -WindowStyle Hidden -File \"%%C\"\"" /f
    )

    REM CMD
    FOR %%C IN ("%DRIVE%\setup\*.cmd") DO (
        REG ADD %ROE%\009 /ve /d %SCRIPTTEXT% /f
        REG ADD %ROE%\009 /v "%%C" /d "%WINDIR%\System32\cmd.exe /min /c \"start /wait %%C\"" /f
    )

    REM BAT
    FOR %%C IN ("%DRIVE%\setup\*.bat") DO (
        REG ADD %ROE%\009 /ve /d %SCRIPTTEXT% /f
        REG ADD %ROE%\009 /v "%%C" /d "%WINDIR%\System32\cmd.exe /min /c \"start /wait %%C\"" /f
    )


    REM Polish Start menu items and reboot
    REG ADD %ROE%\010 /ve /d %RBTTEXT% /f
    if exist "%WINDIR%\setup\scripts\StartMenu.cmd" (
        REG ADD %ROE%\010 /v "01_StartMenu" /d "%WINDIR%\System32\cmd.exe /c \"start /min /wait %WINDIR%\setup\scripts\StartMenu.cmd\"" /f
    )
    REG ADD %ROE%\010 /v "02_Reboot" /d "%WINDIR%\System32\shutdown.exe -r -f -t 0" /f


    REM Enable ROE
    REG ADD %ROE% /d "%WINDIR%\System32\rundll32.exe %WINDIR%\System32\iernonce.dll,RunOnceExProcess" /f

)


exit


Continue in next post
Hi there im abit confused should use I this with the unattended answer file wizard in Ntlite in tantum with this too? Reason why i ask is that i get a error msg in the Windows setup with msg "windows could not parse or process the unattended answer file". NTLite version im running is 2.1.2.8074. Do i need to do anything in addition to what im doing ? Is it just the case of moving the answer file to a particular area on the iso?
 

Attachments

  • IMG_20210724_075147.jpg
    IMG_20210724_075147.jpg
    378.8 KB
Back
Top