@echo off rem File: run_the_same_name_ps1.bat rem Purpose: launcher for PowerShell script with the same base name as this .bat rem (finds pwsh or falls back to Windows PowerShell) rem Author: takraztak rem ================================================== setlocal rem try PowerShell 7 (pwsh) in Program Files set "PS_EXE=%ProgramFiles%\PowerShell\7\pwsh.exe" if exist "%ProgramFiles(x86)%" ( if not exist "%PS_EXE%" set "PS_EXE=%ProgramFiles(x86)%\PowerShell\7\pwsh.exe" ) rem fallback to Windows PowerShell if pwsh not found if not exist "%PS_EXE%" set "PS_EXE=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" rem final fallback: rely on PATH (just the name) if not exist "%PS_EXE%" ( set "PS_EXE=pwsh.exe" ) rem path to the PowerShell script with the same base name as this .bat set "PS1=%~dp0%~n0.ps1" rem Quote paths and forward all args "%PS_EXE%" -NoProfile -ExecutionPolicy Bypass -File "%PS1%" %* endlocal pause exit /b