-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.bat
More file actions
59 lines (47 loc) · 1.68 KB
/
Copy pathinstall.bat
File metadata and controls
59 lines (47 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@echo off
setlocal enabledelayedexpansion
set "REPO=EntexInteractive/Parallel"
set "ASSET_PATTERN=Parallel-.*-cmd-win-x64.zip"
set "INSTALL_ROOT=%ProgramFiles%\Parallel"
set "TMP_DIR=%TEMP%\parallel_%RANDOM%"
set "ZIP_FILE=%TMP_DIR%\parallel.zip"
mkdir "%TMP_DIR%" >nul 2>&1
echo Fetching latest release info...
:: Use PowerShell to safely extract the download URL
for /f "usebackq delims=" %%A in (`powershell -NoLogo -NoProfile -Command "$r = Invoke-WebRequest -UseBasicParsing 'https://api.github.com/repos/%REPO%/releases/latest';" "$json = $r.Content | ConvertFrom-Json;" "$asset = $json.assets | Where-Object { $_.browser_download_url -match '%ASSET_PATTERN%' };" "if ($asset) { $asset.browser_download_url }"`) do (
set "DOWNLOAD_URL=%%A"
)
if "%DOWNLOAD_URL%"=="" (
echo ERROR: Could not find a matching release asset.
exit /b 1
)
echo Downloading latest release...
curl -sSL -o "%ZIP_FILE%" "%DOWNLOAD_URL%"
if not exist "%ZIP_FILE%" (
echo ERROR: Download failed.
exit /b 1
)
echo Installing...
if exist "%INSTALL_ROOT%" rmdir /s /q "%INSTALL_ROOT%"
mkdir "%INSTALL_ROOT%"
powershell -NoLogo -NoProfile -Command "Expand-Archive -Path '%ZIP_FILE%' -DestinationPath '%INSTALL_ROOT%' -Force"
:: Find the binary
set "BIN_NAME="
for %%F in ("%INSTALL_ROOT%\parallel*.exe") do (
set "BIN_NAME=%%~nxF"
goto foundbin
)
:foundbin
if "%BIN_NAME%"=="" (
echo ERROR: Could not locate the Parallel executable after extraction.
exit /b 1
)
:: Add to PATH if needed
echo %PATH% | find /i "%INSTALL_ROOT%" >nul
if errorlevel 1 (
echo Adding Parallel to PATH...
setx PATH "%PATH%;%INSTALL_ROOT%" >nul
)
echo Cleaning up...
rmdir /s /q "%TMP_DIR%"
echo Installation complete.