From 86c6e67cba2d379cb0b1b3f49f09a0e8a40f2ec7 Mon Sep 17 00:00:00 2001 From: Augustus <123775785+OlegTheSnowman@users.noreply.github.com> Date: Thu, 3 Jul 2025 06:39:48 +0300 Subject: [PATCH] github installer . bat will now try to use three different downloading methods if the powershell one fails, hopefully that'll fix some things --- git installer.bat | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/git installer.bat b/git installer.bat index bc7701f..b0b4036 100644 --- a/git installer.bat +++ b/git installer.bat @@ -17,6 +17,8 @@ set "SCRIPT_DIR=%~dp0" set "EXTRACT_DIR=%SCRIPT_DIR%gitportable" set "LOG_FILE=%SCRIPT_DIR%git_setup.log" +echo Downloading Git, please wait... It may take a while. + :: Redirect output to log call :main >> "%LOG_FILE%" 2>&1 goto :end @@ -49,9 +51,9 @@ if exist "%EXTRACT_DIR%\" ( ) ) -:: Download Git +:: Download Git using available method echo Downloading Git... -powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%GIT_URL%' -OutFile '%SCRIPT_DIR%%GIT_ARCHIVE%'" +call :download "%GIT_URL%" "%SCRIPT_DIR%%GIT_ARCHIVE%" if %errorlevel% neq 0 ( echo Error: Download failed. goto :done @@ -97,6 +99,33 @@ echo ==================================================== :done exit /b +:download +:: Args: %1 - URL, %2 - Output file + +:: Try PowerShell +where powershell >nul 2>nul +if %errorlevel%==0 ( + powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%~1' -OutFile '%~2'" + if %errorlevel%==0 exit /b 0 +) + +:: Try curl +where curl >nul 2>nul +if %errorlevel%==0 ( + curl -L -o "%~2" "%~1" + if %errorlevel%==0 exit /b 0 +) + +:: Try bitsadmin +where bitsadmin >nul 2>nul +if %errorlevel%==0 ( + bitsadmin /transfer downloadjob /download /priority normal "%~1" "%~2" + if %errorlevel%==0 exit /b 0 +) + +echo Error: No supported downloader (certutil, PowerShell, curl, bitsadmin) found. +exit /b 1 + :end echo. echo Log saved to: %LOG_FILE%