github installer . bat will now try to use three different downloading methods if the powershell one fails, hopefully that'll fix some things

This commit is contained in:
Augustus
2025-07-03 06:39:48 +03:00
parent 9394853c1c
commit 86c6e67cba

View File

@@ -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%