Initial commit
This commit is contained in:
99
scripts/powershell/install-apps-winget.ps1
Normal file
99
scripts/powershell/install-apps-winget.ps1
Normal file
@@ -0,0 +1,99 @@
|
||||
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
||||
$ErrorActionPreference = 'Continue'
|
||||
|
||||
Write-Host "[*] Installing applications using winget"
|
||||
Write-Host ""
|
||||
|
||||
# Applications to install
|
||||
$apps = @(
|
||||
@{Name="Google Chrome"; Id="Google.Chrome"},
|
||||
@{Name="7-Zip"; Id="7zip.7zip"},
|
||||
@{Name="AnyDesk"; Id="AnyDeskSoftwareGmbH.AnyDesk"},
|
||||
@{Name="LINE"; Id="LINE.LINE"},
|
||||
@{Name="Adobe Reader"; Id="Adobe.Acrobat.Reader.64-bit"}
|
||||
)
|
||||
|
||||
$installedCount = 0
|
||||
$totalApps = $apps.Count
|
||||
|
||||
Write-Host "Installing $totalApps applications..."
|
||||
Write-Host ""
|
||||
|
||||
foreach ($app in $apps) {
|
||||
Write-Host "[$($installedCount + 1)/$totalApps] Installing $($app.Name)..."
|
||||
|
||||
try {
|
||||
# First check if already installed
|
||||
$checkResult = & winget list $app.Id 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host " [SKIP] $($app.Name) already installed"
|
||||
$installedCount++
|
||||
continue
|
||||
}
|
||||
|
||||
# Install the application
|
||||
Write-Host " Downloading and installing..."
|
||||
$installResult = & winget install $app.Id --accept-package-agreements --accept-source-agreements --silent
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host " [OK] $($app.Name) installed successfully"
|
||||
$installedCount++
|
||||
} else {
|
||||
Write-Host " [!] $($app.Name) installation may have failed"
|
||||
Write-Host " Checking if it was actually installed..."
|
||||
|
||||
# Double-check installation
|
||||
Start-Sleep -Seconds 2
|
||||
$verifyResult = & winget list $app.Id 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host " [OK] $($app.Name) verified as installed"
|
||||
$installedCount++
|
||||
} else {
|
||||
Write-Host " [ERROR] $($app.Name) installation failed"
|
||||
}
|
||||
}
|
||||
|
||||
} catch {
|
||||
Write-Host " [ERROR] Exception installing $($app.Name): $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Start-Sleep -Seconds 1
|
||||
}
|
||||
|
||||
Write-Host "=== Installation Summary ==="
|
||||
Write-Host "Successfully processed: $installedCount / $totalApps applications"
|
||||
Write-Host ""
|
||||
|
||||
# Verification
|
||||
Write-Host "Verification check:"
|
||||
|
||||
$verificationPaths = @(
|
||||
@{Name="Chrome"; Path="C:\Program Files\Google\Chrome\Application\chrome.exe"},
|
||||
@{Name="7-Zip"; Path="C:\Program Files\7-Zip\7z.exe"},
|
||||
@{Name="AnyDesk"; Path="C:\Program Files (x86)\AnyDesk\AnyDesk.exe"},
|
||||
@{Name="Adobe Reader"; Path="C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"}
|
||||
)
|
||||
|
||||
foreach ($check in $verificationPaths) {
|
||||
if (Test-Path $check.Path) {
|
||||
Write-Host " [OK] $($check.Name) - Found"
|
||||
} else {
|
||||
Write-Host " [?] $($check.Name) - Not found at expected location"
|
||||
}
|
||||
}
|
||||
|
||||
# LINE has a different installation path (per-user)
|
||||
$lineUserPath = "C:\Users\$env:USERNAME\AppData\Local\LINE\bin\LineLauncher.exe"
|
||||
$lineSystemPath = "C:\Program Files\LINE\bin\LineLauncher.exe"
|
||||
|
||||
if ((Test-Path $lineUserPath) -or (Test-Path $lineSystemPath)) {
|
||||
Write-Host " [OK] LINE - Found"
|
||||
} else {
|
||||
Write-Host " [?] LINE - Not found"
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Installation completed!"
|
||||
Write-Host "Applications may take a few moments to appear in Start Menu."
|
||||
Write-Host "Some applications may require a system restart to function properly."
|
||||
Reference in New Issue
Block a user