@echo off
setlocal

:: Set default path
set "defaultPath=%LOCALAPPDATA%\Supermium\User Data\WidevineCdm"
set "fileName=widevinecdm.dll"

:: Check if a file name was provided
:: if "%fileName%"=="" (
    echo Usage: %0 filename
    echo Searching in default path: %defaultPath%
    set "searchPath=%defaultPath%"
rem ) else (
rem    set "searchPath=%~1"
rem )

:: Initialize a variable to store the found file path
set "foundFile="

:: Search for the file in the specified path and its subdirectories
for /r "%searchPath%" %%F in (*%fileName%*) do (
    set "foundFile=%%F"
    goto :found
)

:found
if defined foundFile (
    echo Found file: "%foundFile%"
    start "" "widevine_patch.exe" "%foundFile%"
) else (
    echo File not found: "%searchPath%\%fileName%"
)

endlocal