Add some extra features

This commit is contained in:
Calyx Hikari 2025-06-29 14:09:43 +08:00
parent a238ee84d2
commit 427eb4abfa
4 changed files with 103 additions and 21 deletions

27
32
View file

@ -1,6 +1,3 @@
# This script is hosted on <b>https://get.msvc.win/32</b> for <b><a href="https://msvc.win/">MSVC Win Project</a></b><br />To get started, run <b>irm get.msvc.win/32 | iex</b> inside of PowerShell<hr><pre>
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Main {
@ -41,20 +38,37 @@ 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"
$regionalWorkaround = ""
}
if ($useProxy) {
$regionalWorkaround = "--all-proxy=$proxyAddress"
}
Invoke-WebRequest -Uri $aria2Url -OutFile $aria2Zip
Expand-Archive -Path $aria2Zip -DestinationPath $aria2Dir -Force
@ -85,6 +99,7 @@ function Main {
"--max-connection-per-server=8",
"--split=8",
"--min-split-size=1M",
"$regionalWorkaround",
"`"$($item.Url)`""
) -NoNewWindow -Wait
}
@ -97,9 +112,9 @@ function Main {
# --- Install VC++ Redistributables ---
foreach ($item in $downloads | Where-Object { $_.Name -like "vcredist*" }) {
$exePath = Join-Path $tempDir $item.Name
$args = if ($item.Year -in @("2005", "2008")) { "/q" } else { "/quiet /norestart" }
$arguments = if ($item.Year -in @("2005", "2008")) { "/q" } else { "/quiet /norestart" }
Write-Host "Installing $($item.Name)..."
Start-Process -FilePath $exePath -ArgumentList $args -Wait
Start-Process -FilePath $exePath -ArgumentList $arguments -Wait
}
# --- Cleanup ---

33
64
View file

@ -1,6 +1,3 @@
# This script is hosted on <b>https://get.msvc.win/64</b> for <b><a href="https://msvc.win/">MSVC Win Project</a></b><br />To get started, run <b>irm get.msvc.win/64 | iex</b> inside of PowerShell<hr><pre>
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Main {
@ -9,6 +6,12 @@ function Main {
return 1
}
$procArch = $Env:PROCESSOR_ARCHITECTURE
if ($procArch -eq 'x86') {
Write-Warning "This script does not support 32-bit Windows. Exiting..."
return 1
}
$flagPath = "$env:TEMP\elevation_success.flag"
if (Test-Path $flagPath) { Remove-Item $flagPath -ErrorAction SilentlyContinue }
@ -41,20 +44,37 @@ 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-64bit-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-64bit-build1.zip"
$regionalWorkaround = ""
}
if ($useProxy) {
$regionalWorkaround = "--all-proxy=$proxyAddress"
}
Invoke-WebRequest -Uri $aria2Url -OutFile $aria2Zip
Expand-Archive -Path $aria2Zip -DestinationPath $aria2Dir -Force
@ -90,6 +110,7 @@ function Main {
"--max-connection-per-server=8",
"--split=8",
"--min-split-size=1M",
"$regionalWorkaround",
"`"$($item.Url)`""
) -NoNewWindow -Wait
}
@ -97,9 +118,9 @@ function Main {
# --- Install VC++ Redistributables ---
foreach ($item in $downloads | Where-Object { $_.Name -like "vcredist*" }) {
$exePath = Join-Path $tempDir $item.Name
$args = if ($item.Year -in @("2005", "2008")) { "/q" } else { "/quiet /norestart" }
$arguments = if ($item.Year -in @("2005", "2008")) { "/q" } else { "/quiet /norestart" }
Write-Host "Installing $($item.Name)..."
Start-Process -FilePath $exePath -ArgumentList $args -Wait
Start-Process -FilePath $exePath -ArgumentList $arguments -Wait
}
# --- Cleanup ---

28
dx
View file

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

View file

@ -9,6 +9,8 @@ function Main {
return 1
}
$procArch = $Env:PROCESSOR_ARCHITECTURE
$flagPath = "$env:TEMP\elevation_success.flag"
if (Test-Path $flagPath) { Remove-Item $flagPath -ErrorAction SilentlyContinue }
@ -41,20 +43,39 @@ 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-64bit-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-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
@ -81,6 +102,9 @@ function Main {
# --- Download everything up front ---
foreach ($item in $downloads) {
if ($item.Name -Match "x64" -and $procArch -ne "AMD64") {
continue
}
$outFile = Join-Path $tempDir $item.Name
Write-Host "Downloading $($item.Name)..."
Start-Process -FilePath $aria2Exe -ArgumentList @(
@ -91,6 +115,7 @@ function Main {
"--max-connection-per-server=8",
"--split=8",
"--min-split-size=1M",
"$regionalWorkaround",
"`"$($item.Url)`""
) -NoNewWindow -Wait
}
@ -102,10 +127,13 @@ function Main {
# --- Install VC++ Redistributables ---
foreach ($item in $downloads | Where-Object { $_.Name -like "vcredist*" }) {
if ($item.Name -Match "x64" -and $procArch -ne "AMD64") {
continue
}
$exePath = Join-Path $tempDir $item.Name
$args = if ($item.Year -in @("2005", "2008")) { "/q" } else { "/quiet /norestart" }
$arguments = if ($item.Year -in @("2005", "2008")) { "/q" } else { "/quiet /norestart" }
Write-Host "Installing $($item.Name)..."
Start-Process -FilePath $exePath -ArgumentList $args -Wait
Start-Process -FilePath $exePath -ArgumentList $arguments -Wait
}
# --- Cleanup ---