Last active
April 11, 2020 12:46
-
-
Save lboulard/451a5318d6e546226997bd7f69d4be69 to your computer and use it in GitHub Desktop.
Python script inside dosbatch file
This file contains hidden or 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
0<0# : ^ | |
''' | |
:: Keep a python script inside a bat file | |
:: Source https://stackoverflow.com/a/41651933 | |
@SETLOCAL ENABLEEXTENSIONS | |
@py -3 -x -B "%~f0" %* | |
@SET ERR=%ERRORLEVEL% | |
@:: Pause if not interactive | |
@ECHO %cmdcmdline% | FIND /i "%~0" >NUL | |
@IF NOT ERRORLEVEL 1 PAUSE | |
@ENDLOCAL&EXIT /B %ERR% | |
''' | |
print("Hello world from " + __file__) | |
# Local Variables: | |
# coding: utf-8-dos | |
# mode: python | |
# indent-tabs-mode: nil | |
# tab-width: 4 | |
# python-indent-offset: 4 | |
# fill-column: 80 | |
# End: | |
# vim: set ff=dos ft=python et sts=4 ts=4 tw=80: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment