How can I setup a Batch file to recurse 2 levels of a directory and run a command?

I’m trying to write a Batch file that will recurse 1 level and for all the directories in that level, go in to each of them and run commands.

For example. In every directory in my current directory, I want to go down 1 subdirectory. In every directory in this subdirectory, I want to go down 1 subdirectory more and then run commands.

C:
 └----Program Files
 │         ├-------------- Corsair
 │         │                 └------- CORSAIR iCUE Software
 │         └-------------- Canon
 │                           └------- Quick Menu
 │                           └------- EISRegistration
 └----Program Files (86)
           ├-------------- AMD
           │                 ├------- Chipset_IODrivers
           │                 └------- I2C Driver
           └-------------- ASUS
                             ├------- AXSP
                             └------- 4.00.42

So the commands I want to run are in the last level of the diagram only and don’t recurse any further.

I’ve found several scripts on the net but none of them work. They either do nothing at all or they don’t actually recurse deep enough.

Here is an example one I found.

@echo off
SETLOCAL EnableDelayedExpansion

REM Define the starting directory (e.g., the directory where the batch file is located)
SET "start_dir=."

REM Loop through the first level of subdirectories
FOR /D %%A IN (*) DO (
    REM Change to the first level directory
    CD "%%A"
    
    REM Loop through the second level of subdirectories within the first level directory
    FOR /D %%B IN (*) DO (
        REM Change to the second level directory
        PUSHD "%%B"

        REM --- Place your commands here ---
        ECHO Currently in: !CD!
        REM Replace the ECHO command above with your actual commands
        your_command_here
        
        REM Return to the previous directory (first level)
        POPD
    )
    
    REM Return to the starting directory
    CD..
)

ENDLOCAL
ECHO All operations complete.
pause

This will recurse 2 levels but remains in the first directory of the 2nd level and doesn’t change to the other directories.