Skip to content

Instantly share code, notes, and snippets.

@zfwf
Created January 29, 2017 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zfwf/c8375e833daae68d2764dcb2e36fcb70 to your computer and use it in GitHub Desktop.
Save zfwf/c8375e833daae68d2764dcb2e36fcb70 to your computer and use it in GitHub Desktop.
polyglot to run python in windows batch
@SETLOCAL ENABLEDELAYEDEXPANSION & CALL "%~f0" & (IF NOT ERRORLEVEL 1 (python -x "%~f0" %*) ELSE (ECHO No python environment found on path)) & PAUSE & EXIT /B !ERRORLEVEL!
#%0 is the command itself. So %~f0 expands to the full path of the batch file. %* stands for all command line parameters except %0.
#do something in python
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment