Skip to content

Instantly share code, notes, and snippets.

@jeanfbrito
Created April 12, 2025 06:21
Show Gist options
  • Save jeanfbrito/08e54459c5890439aae1d22653ec4119 to your computer and use it in GitHub Desktop.
Save jeanfbrito/08e54459c5890439aae1d22653ec4119 to your computer and use it in GitHub Desktop.

Usage After Installation

  1. Open a new Command Prompt or PowerShell to ensure your updated PATH is recognized.
  2. Navigate to the folder where you want to save the file (e.g., cd D:\Downloads).
  3. Run:
    aria2c https://example.com/large-file.iso
  4. The file will download in the current directory, using the default settings from aria2.conf (10 connections, resume, etc.).

Enjoy faster downloads with aria2!

<#
.SYNOPSIS
Installs aria2 on Windows, sets up default configuration, and adds to PATH.
.DESCRIPTION
- Creates the folder C:\Tools\aria2.
- Downloads aria2 64-bit (version 1.36.0).
- Extracts all files into C:\Tools\aria2.
- Creates aria2.conf with default settings (resume, 10 connections, etc.).
- Adds C:\Tools\aria2 to the user PATH.
#>
[CmdletBinding()]
param()
Write-Host "`n=== Starting aria2 installation... ===`n"
# 1) Create the target folder if it doesn't exist
$destFolder = "C:\Tools\aria2"
if (!(Test-Path $destFolder)) {
New-Item -ItemType Directory -Force -Path $destFolder | Out-Null
Write-Host "Created folder: $destFolder"
} else {
Write-Host "Folder already exists: $destFolder"
}
# 2) Download aria2 release to %TEMP%
$Aria2Url = "https://github.com/aria2/aria2/releases/download/release-1.36.0/aria2-1.36.0-win-64bit-build1.zip"
$ZipPath = "$env:TEMP\aria2_temp.zip"
Write-Host "`nDownloading aria2 from $Aria2Url..."
Invoke-WebRequest -Uri $Aria2Url -OutFile $ZipPath
Write-Host "Download complete: $ZipPath"
# 3) Unzip to destination folder
Write-Host "`nExtracting zip file..."
Expand-Archive -Path $ZipPath -DestinationPath $destFolder -Force
Write-Host "Extraction complete."
# 4) Move the extracted files from subfolder to C:\Tools\aria2
# Typically, they are in: C:\Tools\aria2\aria2-1.36.0-win-64bit-build1
$extractedFolder = Join-Path $destFolder "aria2-1.36.0-win-64bit-build1"
if (Test-Path $extractedFolder) {
Move-Item -Path (Join-Path $extractedFolder "*") -Destination $destFolder -Force
Remove-Item -Path $extractedFolder -Recurse -Force
Write-Host "`nMoved extracted files to $destFolder"
} else {
Write-Host "`nWARNING: $extractedFolder not found. Check the version/paths."
}
# 5) Create aria2.conf with recommended settings
$configFile = Join-Path $destFolder "aria2.conf"
$configContent = @"
# Resume downloads when possible
continue=true
# Parallel connections
max-connection-per-server=10
split=10
min-split-size=20M
# Disable pre-allocation on Windows
file-allocation=none
"@
Write-Host "`nCreating aria2.conf: $configFile"
$configContent | Out-File $configFile -Encoding UTF8
Write-Host "Configuration file created."
# 6) Add C:\Tools\aria2 to the user PATH
# Change to "Machine" for all users (run as admin if so).
$envScope = "User"
$oldPath = [System.Environment]::GetEnvironmentVariable("Path", $envScope)
if ($oldPath -notlike "*$destFolder*") {
$newPath = $oldPath + ";$destFolder"
[System.Environment]::SetEnvironmentVariable("Path", $newPath, $envScope)
Write-Host "`nAdded '$destFolder' to the PATH ($envScope scope)."
} else {
Write-Host "`n'$destFolder' is already in PATH."
}
Write-Host "`n=== aria2 installation complete! ==="
Write-Host "Open a NEW Command Prompt or PowerShell and type:"
Write-Host " aria2c https://example.com/file.iso"
Write-Host "The file will be downloaded into the CURRENT directory."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment