From e71a97ad31a5c563440d79359eebb26c6e50892c Mon Sep 17 00:00:00 2001 From: Dragohn Date: Thu, 19 Oct 2023 23:59:54 +0200 Subject: [PATCH 1/2] Update AdminLaunchOption.bat --- AdminLaunchOption.bat | 304 +++++++++++++++++------------------------- 1 file changed, 121 insertions(+), 183 deletions(-) diff --git a/AdminLaunchOption.bat b/AdminLaunchOption.bat index 90a6bcc6..764b3b41 100644 --- a/AdminLaunchOption.bat +++ b/AdminLaunchOption.bat @@ -97,36 +97,76 @@ IF NOT DEFINED POWERSHELLCORE_VERSION ( choco upgrade powershell-core -y -n ) -:CheckforPython3.11 -echo %date% %time% - Checking for Python 3.11 installation >> %LOGFILE% -choco list --local-only | find "python 3.11" > nul -if errorlevel 1 ( - echo Python 3.11 not detected. Installing... >> %LOGFILE% - choco install python --version 3.11.0 -y -n -) ELSE ( - echo Python 3.11 already installed >> %LOGFILE% +:Check-Python311 +echo Checking for Python in C:\Python311... >> %LOGFILE% +if exist "C:\Python311\python.exe" ( + echo Found C:\Python311\python.exe >> %LOGFILE% + "C:\Python311\python.exe" --version >> %LOGFILE% +) else ( + echo Python not found in C:\Python311! >> %LOGFILE% + set /p user_input="Do you want to download and install Python 3.11? (yes/no): " + if /i "%user_input%"=="yes" ( +:: Define Python URL and destination +set PythonURL=https://www.python.org/ftp/python/3.11.6/python-3.11.6-amd64.exe +set PythonDestination=C:\Temp\python-3.11.6-amd64.exe + +:: Attempt download using curl +echo %date% %time% - Attempting Python download using curl >> %LOGFILE% +curl -L -o %PythonDestination% %PythonURL% +if "%errorlevel%"=="0" ( + goto InstallPython +) else ( + echo %date% %time% - Python download failed with curl >> %LOGFILE% + goto TryPythonDownloadPowerShell ) -:CheckforPython3.12 -echo %date% %time% - Checking for Python 3.12 installation >> %LOGFILE% -choco list --local-only | find "python 3.12" > nul -if errorlevel 1 ( - echo Python 3.12 not detected. Installing... >> %LOGFILE% - choco install python --version 3.12.0 -y -n -) ELSE ( - echo Python 3.12 already installed >> %LOGFILE% +:TryPythonDownloadPowerShell +:: Attempt download using pwsh (PowerShell) +echo %date% %time% - Attempting Python download using PowerShell >> %LOGFILE% +pwsh -Command "Invoke-WebRequest -Uri '%PythonURL%' -OutFile '%PythonDestination%'" +if "%errorlevel%"=="0" ( + goto InstallPython +) else ( + echo %date% %time% - Python download failed with PowerShell >> %LOGFILE% + goto TryPythonDownloadAria2 ) -:CheckfornewerversionsofPython -echo %date% %time% - Checking for the latest version of Python >> %LOGFILE% -choco list --local-only | find "python" > nul -if errorlevel 1 ( - echo Latest version of Python not detected. Installing... >> %LOGFILE% - choco install python -y -n && goto :Beginactualscriptcommands -) ELSE ( - echo The latest version of Python already installed >> %LOGFILE% +:TryPythonDownloadAria2 +:: Attempt download using aria2 +echo %date% %time% - Attempting Python download using aria2 >> %LOGFILE% +aria2c -o %PythonDestination% %PythonURL% +if "%errorlevel%"=="0" ( + goto InstallPython +) else ( + echo %date% %time% - Python download failed with aria2 >> %LOGFILE% + goto TryPythonDownloadWget +) + +:TryPythonDownloadWget +:: Attempt download using wget +echo %date% %time% - Attempting Python download using wget >> %LOGFILE% +wget -O %PythonDestination% %PythonURL% +if "%errorlevel%"=="0" ( + goto InstallPython +) else ( + echo %date% %time% - Python download failed with wget >> %LOGFILE% + echo Failed to download Python 3.11.6. Please check your internet connection or try again later. >> %LOGFILE% + exit /b +) + +:InstallPython +echo Installing Python 3.11... >> %LOGFILE% +C:\Temp\python-3.11.6-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 +del /f "C:\Temp\python-3.11.6-amd64.exe" +echo Python 3.11 installation completed >> %LOGFILE% + echo Installing Python 3.11... >> %LOGFILE% + C:\Temp\python-3.11.6-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 + del /f "C:\Temp\python-3.11.6-amd64.exe" + echo Python 3.11 installation completed >> %LOGFILE% + ) else ( + echo Skipping Python installation >> %LOGFILE% + ) ) -:: You can add newer versions in a similar manner... cls @@ -145,106 +185,82 @@ if errorlevel 1 ( ) ) -echo Installing/upgrading setuptools for Python 3.12... >> %LOGFILE% -"C:\Python312\python.exe" -m pip install --upgrade setuptools +echo Installing/upgrading setuptools for Python 3.11... >> %LOGFILE% +"C:\Python311\python.exe" -m pip install --upgrade setuptools if errorlevel 1 ( - echo Error: Failed to install/upgrade setuptools using Python 3.12 >> %LOGFILE% - "C:\Python311\python.exe" -m pip install --upgrade setuptools - if errorlevel 1 ( - echo Error: Failed to install/upgrade setuptools using Python 3.11 as well >> %LOGFILE% - ) else ( - echo Success: setuptools installed/upgraded successfully using Python 3.11 >> %LOGFILE% - ) -) ELSE ( - echo Success: setuptools installed/upgraded successfully using Python 3.12 >> %LOGFILE% + echo Error: Failed to install/upgrade setuptools >> %LOGFILE% +) else ( + echo Success: setuptools installed/upgraded successfully>> %LOGFILE% ) -echo Installing/upgrading pyqt5-tools for Python 3.12... >> %LOGFILE% -"C:\Python312\python.exe" -m pip install --upgrade pyqt5-tools +echo Installing/upgrading pyqt5-tools for Python 3.11... >> %LOGFILE% +"C:\Python311\python.exe" -m pip install --upgrade pyqt5-tools if errorlevel 1 ( - echo Error: Failed to install/upgrade pyqt5-tools using Python 3.12 >> %LOGFILE% - "C:\Python311\python.exe" -m pip install --upgrade pyqt5-tools - if errorlevel 1 ( - echo Error: Failed to install/upgrade pyqt5-tools using Python 3.11 as well >> %LOGFILE% - ) else ( - echo Success: pyqt5-tools installed/upgraded successfully using Python 3.11 >> %LOGFILE% - ) -) ELSE ( - echo Success: pyqt5-tools installed/upgraded successfully using Python 3.12 >> %LOGFILE% + echo Error: Failed to install/upgrade pyqt5-tools >> %LOGFILE% +) else ( + echo Success: pyqt5-tools installed/upgraded successfully >> %LOGFILE% ) -echo Installing/upgrading PyQt5-stubs for Python 3.12... >> %LOGFILE% -"C:\Python312\python.exe" -m pip install --upgrade PyQt5-stubs +echo Installing/upgrading PyQt5-stubs for Python 3.11... >> %LOGFILE% +"C:\Python311\python.exe" -m pip install --upgrade PyQt5-stubs if errorlevel 1 ( - echo Error: Failed to install/upgrade PyQt5-stubs using Python 3.12 >> %LOGFILE% - "C:\Python311\python.exe" -m pip install --upgrade PyQt5-stubs - if errorlevel 1 ( - echo Error: Failed to install/upgrade PyQt5-stubs using Python 3.11 as well >> %LOGFILE% - ) else ( - echo Success: PyQt5-stubs installed/upgraded successfully using Python 3.11 >> %LOGFILE% - ) -) ELSE ( - echo Success: PyQt5-stubs installed/upgraded successfully using Python 3.12 >> %LOGFILE% + echo Error: Failed to install/upgrade PyQt5-stubs >> %LOGFILE% +) else ( + echo Success: PyQt5-stubs installed/upgraded successfully >> %LOGFILE% ) -echo Installing/upgrading pyqtgraph for Python 3.12... >> %LOGFILE% -"C:\Python312\python.exe" -m pip install --upgrade pyqtgraph +echo Installing/upgrading pyqtgraph for Python 3.11... >> %LOGFILE% +"C:\Python311\python.exe" -m pip install --upgrade pyqtgraph if errorlevel 1 ( - echo Error: Failed to install/upgrade pyqtgraph using Python 3.12 >> %LOGFILE% - "C:\Python311\python.exe" -m pip install --upgrade pyqtgraph - if errorlevel 1 ( - echo Error: Failed to install/upgrade pyqtgraph using Python 3.11 as well >> %LOGFILE% - ) else ( - echo Success: pyqtgraph installed/upgraded successfully using Python 3.11 >> %LOGFILE% - ) -) ELSE ( - echo Success: pyqtgraph installed/upgraded successfully using Python 3.12 >> %LOGFILE% + echo Error: Failed to install/upgrade pyqtgraph >> %LOGFILE% +) else ( + echo Success: pyqtgraph installed/upgraded successfully >> %LOGFILE% ) -echo Installing/upgrading requests for Python 3.12... >> %LOGFILE% -"C:\Python312\python.exe" -m pip install --upgrade requests +echo Installing/upgrading requests for Python 3.11... >> %LOGFILE% +"C:\Python311\python.exe" -m pip install --upgrade requests if errorlevel 1 ( - echo Error: Failed to install/upgrade requests using Python 3.12 >> %LOGFILE% - "C:\Python311\python.exe" -m pip install --upgrade requests - if errorlevel 1 ( - echo Error: Failed to install/upgrade requests using Python 3.11 as well >> %LOGFILE% - ) else ( - echo Success: requests installed/upgraded successfully using Python 3.11 >> %LOGFILE% - ) -) ELSE ( - echo Success: requests installed/upgraded successfully using Python 3.12 >> %LOGFILE% + echo Error: Failed to install/upgrade requests >> %LOGFILE% +) else ( + echo Success: requests installed/upgraded successfully >> %LOGFILE% ) -echo Installing/upgrading psutil for Python 3.12... >> %LOGFILE% -"C:\Python312\python.exe" -m pip install --upgrade psutil +echo Installing/upgrading psutil for Python 3.11... >> %LOGFILE% +"C:\Python311\python.exe" -m pip install --upgrade psutil if errorlevel 1 ( - echo Error: Failed to install/upgrade psutil using Python 3.12 >> %LOGFILE% - "C:\Python311\python.exe" -m pip install --upgrade psutil - if errorlevel 1 ( - echo Error: Failed to install/upgrade psutil using Python 3.11 as well >> %LOGFILE% - ) else ( - echo Success: psutil installed/upgraded successfully using Python 3.11 >> %LOGFILE% - ) -) ELSE ( - echo Success: psutil installed/upgraded successfully using Python 3.12 >> %LOGFILE% + echo Error: Failed to install/upgrade psutil >> %LOGFILE% +) else ( + echo Success: psutil installed/upgraded successfully >> %LOGFILE% ) -echo Installing/upgrading pywin32 for Python 3.12... >> %LOGFILE% -"C:\Python312\python.exe" -m pip install --upgrade pywin32 +echo Installing/upgrading pywin32 for Python 3.11... >> %LOGFILE% +"C:\Python311\python.exe" -m pip install --upgrade pywin32 if errorlevel 1 ( - echo Error: Failed to install/upgrade pywin32 using Python 3.12 >> %LOGFILE% - "C:\Python311\python.exe" -m pip install --upgrade pywin32 - if errorlevel 1 ( - echo Error: Failed to install/upgrade pywin32 using Python 3.11 as well >> %LOGFILE% - ) else ( - echo Success: pywin32 installed/upgraded successfully using Python 3.11 >> %LOGFILE% - ) -) ELSE ( - echo Success: pywin32 installed/upgraded successfully using Python 3.12 >> %LOGFILE% + echo Error: Failed to install/upgrade pywin32l >> %LOGFILE% +) else ( + echo Success: pywin32 installed/upgraded successfully >> %LOGFILE% ) +echo Installing/upgrading pywinauto for Python 3.11... >> %LOGFILE% +"C:\Python311\python.exe" -m pip install --upgrade pywinauto +if errorlevel 1 ( + echo Error: Failed to install/upgrade pywinauto >> %LOGFILE% +) else ( + echo Success: pywinauto installed/upgraded successfully >> %LOGFILE% +) + +echo Installing/upgrading pywinpty for Python 3.11... >> %LOGFILE% +"C:\Python311\python.exe" -m pip install --upgrade pywinpty +if errorlevel 1( + echo Error: Failed to install/upgrade pywinpty >> %LOGFILE% +) else ( + echo Success: pywinpty installed/upgraded successfully >> %LOGFILE% +) + + + :LoggPreview echo. >> %LOGFILE% echo Installation Summary: >> %LOGFILE% @@ -264,28 +280,12 @@ if /i "%user_input%"=="yes" ( start notepad %LOGFILE% ) -cls && goto :Prompt-User - -:Prompt-User -echo Please choose a branch: -echo 1. Main branch -echo 2. Development branch -set /p branch_choice="Enter your choice (1 or 2): " - -if "%branch_choice%"=="1" ( - set NexToolURL=https://raw.githubusercontent.com/coff33ninja/NexTool-Windows-Suite/main/NexTool.py - goto Download-NexTool -) else if "%branch_choice%"=="2" ( - set NexToolURL=https://raw.githubusercontent.com/coff33ninja/NexTool-Windows-Suite/dev/NexTool-Dev.py - goto Download-NexTool -) else ( - echo Invalid choice. Exiting. - exit /B -) +cls && goto :Download-NexTool :Download-NexTool cls set LOGFILE=%~dp0\download-log.txt +set NexToolURL=https://raw.githubusercontent.com/coff33ninja/NexTool-Windows-Suite/main/NexTool.py :: Initialize log echo %date% %time% - Download Script started > %LOGFILE% @@ -335,69 +335,7 @@ if "%errorlevel%"=="0" ( echo %date% %time% - Download failed with wget >> %LOGFILE% ) -:end -echo %date% %time% - Download process completed >> %LOGFILE% -if exist "%NexToolDestination%" ( - echo Download successful! -) else ( - echo Failed to download NexTool.py. Please check your internet connection or try again later. - echo %date% %time% - Download failed. NexTool.py not found. >> %LOGFILE% -) - -goto Check-Python-Version - -:Check-Python-Version -echo Checking for Python in PATH... >> %LOGFILE% -echo Checking for Python in PATH... -for %%i in (python.exe) do ( - set python_path=%%~$PATH:i - if not "!python_path!"=="" ( - echo Found !python_path! >> %LOGFILE% - echo Found !python_path! - "!python_path!" --version >> %LOGFILE% - "!python_path!" --version - echo. >> %LOGFILE% - echo. - ) -) - -echo Checking common installation locations... >> %LOGFILE% -echo Checking common installation locations... -for %%i in (C:\Python*, C:\Users\%username%\AppData\Local\Programs\Python\Python*) do ( - if exist "%%i\python.exe" ( - echo Found %%i\python.exe >> %LOGFILE% - echo Found %%i\python.exe - "%%i\python.exe" --version >> %LOGFILE% - "%%i\python.exe" --version - echo. >> %LOGFILE% - echo. - ) -) - -cls - -:: List all Python versions and let the user choose -echo Available Python versions: -set count=0 - -for /f "tokens=*" %%i in ('where /R C:\ python.exe') do ( - set /a count+=1 - set python!count!=%%i - echo !count!. %%i -) - -:choice -echo Please select the Python version by number (1-!count!): -set /p selected_python= -if not defined python%selected_python% goto choice - -:: Run the chosen Python version for your script -if exist "%NexToolDestination%" ( - echo Launching NexTool.py - !python%selected_python%! "%NexToolDestination%" -) else ( - echo Failed to download NexTool.py -) +C:\Python311\python.exe "%NexToolDestination%" pause endlocal From b90d5bdcf0e9ad863ff483b51cb8b5b499ef1a50 Mon Sep 17 00:00:00 2001 From: Dragohn Date: Fri, 20 Oct 2023 00:00:32 +0200 Subject: [PATCH 2/2] Update AdminLaunchOption.bat --- AdminLaunchOption.bat | 8 -------- 1 file changed, 8 deletions(-) diff --git a/AdminLaunchOption.bat b/AdminLaunchOption.bat index 764b3b41..85396f58 100644 --- a/AdminLaunchOption.bat +++ b/AdminLaunchOption.bat @@ -159,14 +159,6 @@ echo Installing Python 3.11... >> %LOGFILE% C:\Temp\python-3.11.6-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 del /f "C:\Temp\python-3.11.6-amd64.exe" echo Python 3.11 installation completed >> %LOGFILE% - echo Installing Python 3.11... >> %LOGFILE% - C:\Temp\python-3.11.6-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 - del /f "C:\Temp\python-3.11.6-amd64.exe" - echo Python 3.11 installation completed >> %LOGFILE% - ) else ( - echo Skipping Python installation >> %LOGFILE% - ) -) cls