Created
August 6, 2014 14:55
-
-
Save uranusjr/c7aff766460fabc0e4ee to your computer and use it in GitHub Desktop.
Create a Command Prompt shortcut with %Path% setup for a particular Python distribution
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 | |
set /p PYTHONEXE="Drag and drop python.exe here, and press ENTER: " | |
for %%d in (%PYTHONEXE%) do set PYTHONROOT=%%~dpd | |
:: Strip trailing backslash. | |
set PYTHONROOT=%PYTHONROOT:~0,-1% | |
set PYTHONBAT=%PYTHONROOT%\python341.bat | |
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs" | |
echo @echo off > %PYTHONBAT% | |
echo set PATH=%PYTHONROOT%;%PYTHONROOT%\Scripts;%%PATH%% >> %PYTHONBAT% | |
echo cd /D %HOMEPATH% >> %PYTHONBAT% | |
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT% | |
echo sLinkFile = "%HOMEPATH%\Desktop\Django Environment.lnk" >> %SCRIPT% | |
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT% | |
echo oLink.TargetPath = "%COMSPEC%" >> %SCRIPT% | |
echo oLink.Arguments = "/A /Q /K %PYTHONBAT%" >> %SCRIPT% | |
echo oLink.Save >> %SCRIPT% | |
cscript /nologo %SCRIPT% | |
del %SCRIPT% | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment