mirror of
https://github.com/msvc-win/get.msvc.win.git
synced 2025-12-16 05:07:39 +00:00
Add some extra features
This commit is contained in:
parent
a238ee84d2
commit
427eb4abfa
4 changed files with 103 additions and 21 deletions
28
dx
28
dx
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
# This script is hosted on <b>https://get.msvc.win/</b> for <b><a href="https://msvc.win/">MSVC Win Project</a></b><br />To get started, run <b>irm get.msvc.win | iex</b> inside of PowerShell<hr><pre>
|
||||
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
|
||||
function Main {
|
||||
|
|
@ -41,20 +38,40 @@ function Main {
|
|||
$aria2Dir = Join-Path $tempDir "aria2"
|
||||
$aria2Exe = Join-Path $aria2Dir "aria2c.exe"
|
||||
|
||||
# --- Check User IP location---
|
||||
# --- Check User IP location ---
|
||||
|
||||
$geoInfo = Invoke-RestMethod -Uri 'https://ipapi.co/json/'
|
||||
$countryCode = $geoInfo.country
|
||||
|
||||
# --- Check Proxy Settings ---
|
||||
$webProxy = [System.Net.WebRequest]::GetSystemWebProxy()
|
||||
$uri = New-Object Uri("http://example.com")
|
||||
$proxyUri = $webProxy.GetProxy($uri)
|
||||
|
||||
$useProxy = $proxyUri.Host -ne "example.com"
|
||||
if ($useProxy) {
|
||||
$proxyAddress = $proxyUri.Authority
|
||||
Write-Host "Detected system proxy: $proxyAddress"
|
||||
}
|
||||
|
||||
# --- Ensure aria2c is available ---
|
||||
if (-not (Test-Path $aria2Exe)) {
|
||||
Write-Host "Downloading aria2c..."
|
||||
$aria2Zip = Join-Path $tempDir "aria2.zip"
|
||||
if ($countryCode -eq 'CN') {
|
||||
$aria2Url = "https://gitee.com/HikariCalyx/OSTRemote/releases/download/v1.0/aria2-1.37.0-win-32bit-build1.zip"
|
||||
# Workaround for specific Chinese ISPs that would not resolve domains properly like aka.ms
|
||||
$regionalWorkaround = "--async-dns-server=223.5.5.5"
|
||||
}
|
||||
else {
|
||||
$aria2Url = "https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-32bit-build1.zip"
|
||||
$aria2Url = "https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip"
|
||||
$regionalWorkaround = ""
|
||||
}
|
||||
if ($useProxy) {
|
||||
$regionalWorkaround = "--all-proxy=$proxyAddress"
|
||||
}
|
||||
if ($procArch -ne "AMD64") {
|
||||
$aria2Url = $aria2Url.Replace("64bit", "32bit")
|
||||
}
|
||||
Invoke-WebRequest -Uri $aria2Url -OutFile $aria2Zip
|
||||
Expand-Archive -Path $aria2Zip -DestinationPath $aria2Dir -Force
|
||||
|
|
@ -79,6 +96,7 @@ function Main {
|
|||
"--max-connection-per-server=8",
|
||||
"--split=8",
|
||||
"--min-split-size=1M",
|
||||
"$regionalWorkaround",
|
||||
"`"$($item.Url)`""
|
||||
) -NoNewWindow -Wait
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue