RunOnceEX is no longer executed

Discussion in 'Windows 11' started by MIMMO61, Jan 23, 2023.

  1. MIMMO61

    MIMMO61 MDL Senior Member

    Aug 19, 2009
    356
    106
    10
  2. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,784
    19,355
    180
    Code:
    for %%w IN (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 %%w:\sources\install.wim SET CDROM=%%
    
    Should be:
    
    for %%w IN (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 %%w:\sources\install.wim SET CDROM=%%w
    
    As the CDROM variable will never be set correctly to the drive letter in your example.

    Another possible explanation:
    Some motherboards may have a dummy/invalid MSDM table which confuses the Windows setup into ignoring most of the oobe stages including Oobe.cmd and SetupComplete.cmd. To get around that for a test use a ei.cfg file as below to force the Setup to ignore any MSDM table and present the Edition list for selection.

    Off the shelf Gigabyte and some ASUS, MSI boards may have a dummy/invalid SLIC and/or MSDM table.

    IoT LTSC i think also will ignore any OOBE scripts by default.

    Ei.cfg - place in Sources folder.
    Code:
    [Channel]
    _Default
    [VL]
    0
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,784
    19,355
    180
    You can do a test of your runonce commands by adding the entries to the registry...

    Then open a admin command prompt (not a standard user non admin as it wont work) then type:

    runonce /Explorer

    This will force the OS to run the commands in the RunOnceEx section... Ideal for testing your runonce settings before a OS deployment.;)

    Obviously this will execute your script like it would be via Setup/$OEM$ , i have used that method to test when things went a bit pear shaped..
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. MIMMO61

    MIMMO61 MDL Senior Member

    Aug 19, 2009
    356
    106
    10
    THANK YOU.
    i tried the correct script
    Code:
    for %%w IN (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 %%w:\sources\install.wim SET CDROM=%%w:
    I placed the file "ei.cfg" in the source folder
    Code:
    [Channel]
    _Default
    [VL]
    0
    Unfortunately I still have the same problem.
     
  5. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,784
    19,355
    180
    Win 11 is getting very weird recently, as a lot of strange things been happening with it...

    Sorry it not fix the issue...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,784
    19,355
    180
    Ok, here is a simple test to see if RunOnceEx is the issue:

    Open a admin cmd prompt on that OS that failed to run your Setupcomplete script and copy paste the below code.

    It should set the Runonce entry then instantly run it - Notepad should open with a blank window.

    Code:
    Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0001" /v "TestLine1" /t REG_SZ /d "||c:\windows\system32\notepad.exe" /f
    
    runonce /Explorer
    
    
    If it fails to 'run' notepad then the issue is with Win 11.

    If it opens Notepad then the issue is somewhere else...

    If you removed Notepad then you can use another known exe of your choice , i just used notepad as it quick and easy to use.

    The || used before the C:\... is to force a persistent setting much like the ! method in case you are wondering why i used || :)

    Tested the above code test lines in win 10 and w11 22H2, notepad in my case was run.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. berr1sfueller

    berr1sfueller MDL Senior Member

    Nov 17, 2022
    413
    450
    10
    #7 berr1sfueller, Jan 23, 2023
    Last edited: Jan 23, 2023
    If you don't need the itemized display try regular runonce with it's own .cmd. This should work assuming %CDROM% stays the same. Or you could copy Runonce.cmd to the system drive during SetupComplete.
    SetupComplete.cmd:
    Code:
    for %%w IN (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 %%w:\sources\install.wim SET CDROM=%%w
    Reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v "Runonce" /t REG_EXPAND_SZ /d "%CDROM%:\Software\Runonce.cmd" /f
    
    RunOnce.cmd:
    Code:
    @echo off
    for %%w IN (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 %%w:\sources\install.wim SET CDROM=%%w
    "%CDROM%:\Software\Calculator_Legacy_2.0.exe" /f  >NUL
    "%CDROM%:\Software\7z2201.msi /quiet /norestart" /f  >NUL
    EXIT
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. MIMMO61

    MIMMO61 MDL Senior Member

    Aug 19, 2009
    356
    106
    10
    Thank you very much for the valuable information, in the meantime I have performed numerous tests and installations, and found the cause and solution to the problem.
    Since a few days to save the number usb sticks, I created the bootable usb stick not as I always did with RUFUS but with Ventoy so that I can put in more ISOs of operating systems and tools.
    And it is precisely the usb pen created with Ventoy that does not allow me to run the RunOnceEx, the usb pen created with Rufus works without problems, maybe it interacts with the ISO, I don't know what to think.
     
  9. MIMMO61

    MIMMO61 MDL Senior Member

    Aug 19, 2009
    356
    106
    10