From 73a17baeec38990bce67331fb83a227d50a9136a Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sat, 17 Nov 2018 09:42:51 +0000 Subject: [PATCH] samples(run_python): fix registry values querying --- samples/_winpack_run_python_sample.cmd | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/samples/_winpack_run_python_sample.cmd b/samples/_winpack_run_python_sample.cmd index b2f99af6d7..5e84e2e954 100644 --- a/samples/_winpack_run_python_sample.cmd +++ b/samples/_winpack_run_python_sample.cmd @@ -30,12 +30,13 @@ GOTO :PYTHON_NOT_FOUND :QUERY_PYTHON SETLOCAL SET PY_VERSION=%1 -FOR /F "tokens=2*" %%A IN ('REG QUERY "HKCU\SOFTWARE\Python\PythonCore\%PY_VERSION%\InstallPath" /reg:64 /ve 2^>NUL ^| FIND "REG_SZ"') DO SET PYTHON_DIR=%%B +SET PYTHON_DIR= +CALL :regquery "HKCU\SOFTWARE\Python\PythonCore\%PY_VERSION%\InstallPath" PYTHON_DIR IF EXIST "%PYTHON_DIR%\python.exe" ( SET "PYTHON=%PYTHON_DIR%\python.exe" GOTO :QUERY_PYTHON_FOUND ) -FOR /F "tokens=2*" %%A IN ('REG QUERY "HKLM\SOFTWARE\Python\PythonCore\%PY_VERSION%\InstallPath" /reg:64 /ve 2^>NUL ^| FIND "REG_SZ"') DO SET PYTHON_DIR=%%B +CALL :regquery "HKLM\SOFTWARE\Python\PythonCore\%PY_VERSION%\InstallPath" PYTHON_DIR IF EXIST "%PYTHON_DIR%\python.exe" ( SET "PYTHON=%PYTHON_DIR%\python.exe" GOTO :QUERY_PYTHON_FOUND @@ -46,7 +47,7 @@ ENDLOCAL EXIT /B 1 :QUERY_PYTHON_FOUND -ECHO Found Python %PY_VERSION% from Windows Registry +ECHO Found Python %PY_VERSION% from Windows Registry: %PYTHON% ENDLOCAL & SET PYTHON=%PYTHON% EXIT /B 0 @@ -112,3 +113,12 @@ EXIT /B %result% set _dir=%_dir:~0,-1% endlocal & set %2=%_dir% EXIT /B 0 + +:regquery name resultVar + SETLOCAL + FOR /F "tokens=*" %%A IN ('REG QUERY "%1" /reg:64 /ve 2^>NUL ^| FIND "REG_SZ"') DO SET _val=%%A + IF "x%_val%x"=="xx" EXIT /B 1 + SET _val=%_val:*REG_SZ=% + FOR /F "tokens=*" %%A IN ("%_val%") DO SET _val=%%A + ENDLOCAL & SET %2=%_val% + EXIT /B 0