Created
October 14, 2016 16:50
-
-
Save avamsi/ed4473b83d6a6a1a051e5e841b5f48e3 to your computer and use it in GitHub Desktop.
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 & python -x %~f0 %* & goto :EOF | |
import os.path | |
import sys | |
import subprocess | |
PATH_PREFIXES = [r'C:\Python27', r'C:\Python27\Scripts', | |
r'C:\Python27\Library\bin', ''] | |
EXTENSIONS = ['.exe', '.cmd', '.bat'] | |
def get_path(path): | |
for path_prefix in PATH_PREFIXES: | |
for extension in EXTENSIONS: | |
runnable = os.path.join(path_prefix, path) + extension | |
if os.path.exists(runnable): | |
return runnable | |
return path | |
args = sys.argv[1:] | |
args[0] = get_path(sys.argv[1]) | |
subprocess.run(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment