add system config
This commit is contained in:
71
main.ps1
71
main.ps1
@@ -31,42 +31,47 @@ foreach ($app in $apps) {
|
||||
Write-Host "Installing: $($app.Name)" -ForegroundColor Yellow
|
||||
Write-Host "=========================================="
|
||||
|
||||
# --- 步骤 A: Winget 安装 ---
|
||||
$wingetArgs = @(
|
||||
"install",
|
||||
"--id", $app.Id,
|
||||
"-e",
|
||||
"--silent",
|
||||
"--accept-package-agreements",
|
||||
"--accept-source-agreements",
|
||||
"--disable-interactivity",
|
||||
"--scope", "machine"
|
||||
)
|
||||
|
||||
# [版本检查逻辑]
|
||||
# 检查 Version 是否存在且不为空字符串
|
||||
if (-not [string]::IsNullOrWhiteSpace($app.Version)) {
|
||||
Write-Host "-> Version: $($app.Version)"
|
||||
$wingetArgs += "-v"
|
||||
$wingetArgs += $app.Version
|
||||
if ($app.Id -eq "System.Config") {
|
||||
# 如果是纯配置项,直接打印跳过信息
|
||||
Write-Host "[System Config] Skipping install..." -ForegroundColor Magenta
|
||||
} else {
|
||||
Write-Host "-> Version: latest"
|
||||
}
|
||||
# --- 步骤 A: Winget 安装 ---
|
||||
$wingetArgs = @(
|
||||
"install",
|
||||
"--id", $app.Id,
|
||||
"-e",
|
||||
"--silent",
|
||||
"--accept-package-agreements",
|
||||
"--accept-source-agreements",
|
||||
"--disable-interactivity",
|
||||
"--scope", "machine"
|
||||
)
|
||||
|
||||
Write-Host "-> Installing via winget..."
|
||||
|
||||
# 执行安装
|
||||
$proc = Start-Process -FilePath "winget" -ArgumentList $wingetArgs -Wait -PassThru -NoNewWindow
|
||||
# [版本检查逻辑]
|
||||
# 检查 Version 是否存在且不为空字符串
|
||||
if (-not [string]::IsNullOrWhiteSpace($app.Version)) {
|
||||
Write-Host "-> Version: $($app.Version)"
|
||||
$wingetArgs += "-v"
|
||||
$wingetArgs += $app.Version
|
||||
} else {
|
||||
Write-Host "-> Version: latest"
|
||||
}
|
||||
|
||||
# 检查安装结果 (0=成功, -1978335189=已安装)
|
||||
if ($proc.ExitCode -eq 0) {
|
||||
Write-Host "[Success]" -ForegroundColor Green
|
||||
} elseif ($proc.ExitCode -eq -1978335189) {
|
||||
Write-Host "[Skip] Already installed" -ForegroundColor Yellow
|
||||
continue # 已经安装的为了避免覆盖配置,也就不配置了
|
||||
} else {
|
||||
Write-Error "[Fail] Error code: $($proc.ExitCode)"
|
||||
continue # 安装失败则跳过后续配置
|
||||
Write-Host "-> Installing via winget..."
|
||||
|
||||
# 执行安装
|
||||
$proc = Start-Process -FilePath "winget" -ArgumentList $wingetArgs -Wait -PassThru -NoNewWindow
|
||||
|
||||
# 检查安装结果 (0=成功, -1978335189=已安装)
|
||||
if ($proc.ExitCode -eq 0) {
|
||||
Write-Host "[Success]" -ForegroundColor Green
|
||||
} elseif ($proc.ExitCode -eq -1978335189) {
|
||||
Write-Host "[Skip] Already installed" -ForegroundColor Yellow
|
||||
continue # 已经安装的为了避免覆盖配置,也就不配置了
|
||||
} else {
|
||||
Write-Error "[Fail] Error code: $($proc.ExitCode)"
|
||||
continue # 安装失败则跳过后续配置
|
||||
}
|
||||
}
|
||||
|
||||
# --- 步骤 B: PostInstall 配置 ---
|
||||
|
||||
Reference in New Issue
Block a user