Last active
May 26, 2023 11:18
-
-
Save JonasGroeger/10417237 to your computer and use it in GitHub Desktop.
Generic .bat file to launch .ps1 file with same name in same directory. Example: You have "start.ps1" to do something. Download this Gist and save as "start.bat". The latter will launch "start.ps1" by double-clicking.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal | |
REM Generic .bat file to launch .ps1 files. | |
REM Name the .bat file like the .ps1 file and you are done. | |
set this_file_no_extension=%~n0 | |
set ps1_file=%this_file_no_extension%.ps1 | |
powershell.exe -ExecutionPolicy Bypass -NoLogo -Noninteractive -NoProfile -File %ps1_file% | |
endlocal |
I made a custom version myself as I needed argument handling and encountered some problems with the -file and -arguments options.
https://gist.github.com/tberta/3cb709091b94e4a1c91511873bad1270
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is perfect, thanks. I was looking for a way to easily make a "double-clickable" .ps1 experience.
May Allah (S.W.T.) bestow upon you His Blessings and Guidance. Ameen.