From a9f068e453240b5867376c8dd31c75f89e82df01 Mon Sep 17 00:00:00 2001 From: dmiller Date: Mon, 27 Feb 2023 18:16:24 +0000 Subject: [PATCH] Update python-wrap.bat to use Zenmap's python if possible, Python3 otherwise --- mswin32/python-wrap.bat | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mswin32/python-wrap.bat b/mswin32/python-wrap.bat index 9b129457b..f96782e57 100755 --- a/mswin32/python-wrap.bat +++ b/mswin32/python-wrap.bat @@ -5,7 +5,7 @@ rem script. It displays an error message if not Python is found. The script rem to run must have the same filename as the batch file, with an extension of rem .py rather than .bat. -setlocal +setlocal EnableDelayedExpansion rem %0 is the name of the batch file. "dpn" means drive, path, filename rem (excluding extension). @@ -16,9 +16,19 @@ if not exist "%PROG%" ( echo because that file does not exist. exit /B 1 ) +set NMAPDIR=%~dp0 -set PATH=%PATH%;C:\Python27;C:\Python26;C:\Python25;C:\Python24 -for %%P in ( python.exe ) do set PYTHON=%%~f$PATH:P +set PATH=%NMAPDIR%\zenmap\bin;%PATH% + +for /D %%P in ("%ProgramFiles%\Python 3.*", + "%ProgramFiles(x86)%\Python 3.*", + "%LocalAppData%\Programs\Python\Python3*" + ) do set PATH=%PATH%;%%~P + +for %%P in ( py.exe, python.exe) do ( + set PYTHON=%%~f$PATH:P + if exist "!PYTHON!" GOTO:EXEC +) if not exist "%PYTHON%" GOTO:NOPYTHON