Skip to content

Instantly share code, notes, and snippets.

@mark05e
Created March 8, 2022 22:58
Show Gist options
  • Save mark05e/3d8c7e00a75f371075f738cf7d086ff1 to your computer and use it in GitHub Desktop.
Save mark05e/3d8c7e00a75f371075f738cf7d086ff1 to your computer and use it in GitHub Desktop.
Launch Powershell Script with same name in the same path
::====================================================================
:: Powershell script launcher
:: ref: https://stackoverflow.com/questions/10137146/is-there-a-way-to-make-a-powershell-script-work-by-double-clicking-a-ps1-file
::=====================================================================
:MAIN
@echo off
for /f "tokens=*" %%p in ("%~p0") do set SCRIPT_PATH=%%p
pushd "%SCRIPT_PATH%"
powershell.exe -sta -c "& {.\%~n0.ps1 %*}"
popd
set SCRIPT_PATH=
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment