@echo off for /f "delims=" %%i in ('where Create-Clip.ps1 2^>nul') do set "_script=%%i" & goto :found echo Error: Create-Clip.ps1 not found in PATH exit /b 1 :found set "_src=%~1" set "_frames=%~2" shift shift set "_rest=" :loop if "%~1"=="" goto done set "_rest=%_rest% %1" shift goto loop :done pwsh.exe -NoProfile -ExecutionPolicy Bypass -File "%_script%" -Source "%_src%" -Frames "%_frames%"%_rest%