神秘的脚本(学校,集训营必备)
2026-03-25 21:53:50
发布于:上海
神秘的ps1小脚本:
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "请以管理员身份运行此脚本" -ForegroundColor Red
exit
}
$tempDir = "$env:TEMP\DevToolsInstall"
if (!(Test-Path -Path $tempDir)) {
New-Item -ItemType Directory -Path $tempDir | Out-Null
}
function Get-Architecture {
return [Environment]::Is64BitOperatingSystem ? "64" : "32"
}
$arch = Get-Architecture
Write-Host "正在安装Python 3.6.1 ($arch位)..." -ForegroundColor Cyan
$pythonUrl = if ($arch -eq "64") {
"https://mirrors.aliyun.com/python/3.6.1/python-3.6.1-amd64.exe"
} else {
"https://mirrors.aliyun.com/python/3.6.1/python-3.6.1.exe"
}
$pythonInstaller = "$tempDir\python-3.6.1.exe"
try {
Invoke-WebRequest -Uri $pythonUrl -OutFile $pythonInstaller
Start-Process -FilePath $pythonInstaller -Args "/quiet InstallAllUsers=1 PrependPath=1" -Wait
Write-Host "Python 3.6.1安装完成" -ForegroundColor Green
}
catch {
Write-Host "Python下载或安装失败: $_" -ForegroundColor Red
}
Write-Host "正在安装Git for Windows ($arch位)..." -ForegroundColor Cyan
$gitUrl = if ($arch -eq "64") {
"https://mirrors.aliyun.com/git-for-windows/v2.40.1.windows.1/Git-2.40.1-64-bit.exe"
} else {
"https://mirrors.aliyun.com/git-for-windows/v2.40.1.windows.1/Git-2.40.1-32-bit.exe"
}
$gitInstaller = "$tempDir\GitSetup.exe"
try {
Invoke-WebRequest -Uri $gitUrl -OutFile $gitInstaller
Start-Process -FilePath $gitInstaller -Args "/VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS=""icons,ext\reg\shellhere,assoc,assoc_sh""" -Wait
Write-Host "Git for Windows安装完成" -ForegroundColor Green
}
catch {
Write-Host "Git下载或安装失败: $_" -ForegroundColor Red
}
Write-Host "正在安装Firefox ($arch位)..." -ForegroundColor Cyan
$firefoxUrl = if ($arch -eq "64") {
"https://download.mozilla.org/?product=firefox-latest-ssl&os=win64&lang=zh-CN"
} else {
"https://download.mozilla.org/?product=firefox-latest-ssl&os=win&lang=zh-CN"
}
$firefoxInstaller = "$tempDir\FirefoxSetup.exe"
try {
Invoke-WebRequest -Uri $firefoxUrl -OutFile $firefoxInstaller
Start-Process -FilePath $firefoxInstaller -Args "/S" -Wait
Write-Host "Firefox安装完成" -ForegroundColor Green
}
catch {
Write-Host "Firefox下载或安装失败: $_" -ForegroundColor Red
}
Write-Host "正在安装Windows Terminal..." -ForegroundColor Cyan
try {
winget install --id=Microsoft.WindowsTerminal -e --accept-package-agreements --accept-source-agreements
Write-Host "Windows Terminal安装完成" -ForegroundColor Green
}
catch {
Write-Host "Windows Terminal安装失败: $_" -ForegroundColor Red
Write-Host "如果未安装winget,请先安装Windows包管理器: https://aka.ms/getwinget"
}
Write-Host "正在安装Dev-C++ ($arch位)..." -ForegroundColor Cyan
$devcppUrl = "https://sourceforge.net/projects/orwelldevcpp/files/latest/download"
$devcppInstaller = "$tempDir\DevCppSetup.exe"
try {
Invoke-WebRequest -Uri $devcppUrl -OutFile $devcppInstaller
Start-Process -FilePath $devcppInstaller -Args "/VERYSILENT /NORESTART" -Wait
Write-Host "Dev-C++安装完成" -ForegroundColor Green
}
catch {
Write-Host "Dev-C++下载或安装失败: $_" -ForegroundColor Red
}
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "所有安装任务已完成" -ForegroundColor Green
全部评论 5
uiimntj ni
2026-03-26 来自 浙江
0666
2026-03-26 来自 广东
0666
2026-03-26 来自 广东
06
怎么用呢2026-03-26 来自 江苏
0a
2026-03-26 来自 浙江
0


































有帮助,赞一个