Cleaner py detection

This commit is contained in:
CorpNewt 2019-06-07 10:52:18 -05:00 committed by GitHub
parent 71227c208f
commit 01e36a77dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,6 +32,7 @@ set "script_name=%~n0.py"
set "thisDir=%~dp0"
set /a tried=0
set "toask=yes"
set "python="
goto checkscript
@ -50,15 +51,10 @@ goto checkpy
:checkpy
REM Get python location
set "python="
FOR /F "tokens=* USEBACKQ" %%F IN (`python -V 2^>^&1`) DO (
set "t=%%F"
if /i "!t:~0,6!" == "python" (
REM Might have python installed - let's check for the store message
if /i "!t:was not found=!" == "!t!" (
REM There was no change - we found it.
set "python=%%F"
)
set "dummypath=%USERPROFILE%\AppData\Local\Microsoft\WindowsApps\python.exe"
FOR /F "tokens=* USEBACKQ" %%F IN (`where python`) DO (
if /i not "%%F" == "!dummypath!" (
set "python=%%F"
)
)
@ -208,8 +204,8 @@ exit /b
REM Python found
cls
if "%*"=="" (
python "!thisDir!!script_name!"
"!python!" "!thisDir!!script_name!"
) else (
python "!thisDir!!script_name!" %*
"!python!" "!thisDir!!script_name!" %*
)
goto :EOF