Skip to content

Instantly share code, notes, and snippets.

@gustavoleo
Created September 18, 2020 17:38
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 gustavoleo/c4e97ee9b7a0c770784bbf5460fcac10 to your computer and use it in GitHub Desktop.
Save gustavoleo/c4e97ee9b7a0c770784bbf5460fcac10 to your computer and use it in GitHub Desktop.
Batch to run Python script from cmd
@echo off
SET RUN_DOTPY=python.exe mercurial.py
SET PYTHON_PATH=C:\dev\Python27
set SCRIPT=
REM Hunt around for python
IF EXIST "python.exe" (
SET SCRIPT=%RUN_DOTPY%
) ELSE (
IF EXIST "%PYTHON_PATH%" (
SET SCRIPT=%PYTHON_PATH%\%RUN_DOTPY%
) ELSE (
IF EXIST %PYTHON% SET SCRIPT=%PYTHON%\%RUN_DOTPY%
)
)
IF NOT "" == "%SCRIPT%" (
%SCRIPT%
pause
) ELSE (
echo.
echo Python.exe is not in the path!
pause
)
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment