163 lines
5.7 KiB
PowerShell
163 lines
5.7 KiB
PowerShell
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
Write-Host "[*] Installing essential applications for User"
|
|
Write-Host "Applications: AnyDesk, LINE, Chrome, 7zip, Adobe Reader"
|
|
Write-Host ""
|
|
|
|
# Function to test if an app is already installed
|
|
function Test-AppInstalled {
|
|
param([string]$AppName, [string]$ProcessName)
|
|
|
|
# Check via Get-WmiObject for installed programs
|
|
$installed = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "*$AppName*" }
|
|
if ($installed) {
|
|
Write-Host " $AppName is already installed: $($installed.Name)"
|
|
return $true
|
|
}
|
|
|
|
# Check via registry (more reliable for some apps)
|
|
$regPaths = @(
|
|
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
|
|
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
|
|
)
|
|
|
|
foreach ($path in $regPaths) {
|
|
$apps = Get-ItemProperty $path -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -like "*$AppName*" }
|
|
if ($apps) {
|
|
Write-Host " $AppName is already installed: $($apps[0].DisplayName)"
|
|
return $true
|
|
}
|
|
}
|
|
|
|
return $false
|
|
}
|
|
|
|
# Function to install via winget
|
|
function Install-ViaWinget {
|
|
param([string]$AppId, [string]$AppName)
|
|
|
|
Write-Host " Trying winget install $AppId"
|
|
try {
|
|
$result = & winget install $AppId --accept-package-agreements --accept-source-agreements --silent
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host " [OK] $AppName installed via winget"
|
|
return $true
|
|
} else {
|
|
Write-Host " Winget install failed for $AppName"
|
|
return $false
|
|
}
|
|
} catch {
|
|
Write-Host " Winget not available or failed: $($_.Exception.Message)"
|
|
return $false
|
|
}
|
|
}
|
|
|
|
# Function to download and install manually
|
|
function Install-Manual {
|
|
param([string]$Url, [string]$FileName, [string]$Args, [string]$AppName)
|
|
|
|
Write-Host " Downloading $AppName from $Url"
|
|
|
|
$downloadPath = Join-Path $env:TEMP $FileName
|
|
try {
|
|
Invoke-WebRequest -Uri $Url -OutFile $downloadPath -UseBasicParsing
|
|
Write-Host " Downloaded to $downloadPath"
|
|
|
|
Write-Host " Installing $AppName..."
|
|
if ($Args) {
|
|
& $downloadPath $Args.Split(' ')
|
|
} else {
|
|
& $downloadPath
|
|
}
|
|
|
|
Start-Sleep -Seconds 3
|
|
|
|
# Clean up
|
|
Remove-Item $downloadPath -Force -ErrorAction SilentlyContinue
|
|
Write-Host " [OK] $AppName installation completed"
|
|
return $true
|
|
|
|
} catch {
|
|
Write-Host " [!] Manual install failed for $AppName: $($_.Exception.Message)"
|
|
return $false
|
|
}
|
|
}
|
|
|
|
Write-Host "[1/5] Installing AnyDesk"
|
|
if (-not (Test-AppInstalled -AppName "AnyDesk" -ProcessName "AnyDesk")) {
|
|
if (-not (Install-ViaWinget -AppId "AnyDeskSoftwareGmbH.AnyDesk" -AppName "AnyDesk")) {
|
|
Install-Manual -Url "https://download.anydesk.com/AnyDesk.exe" -FileName "AnyDesk.exe" -Args "--install --start-with-win --silent" -AppName "AnyDesk"
|
|
}
|
|
} else {
|
|
Write-Host " [SKIP] AnyDesk already installed"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[2/5] Installing LINE"
|
|
if (-not (Test-AppInstalled -AppName "LINE" -ProcessName "LINE")) {
|
|
if (-not (Install-ViaWinget -AppId "LINE.LINE" -AppName "LINE")) {
|
|
Install-Manual -Url "https://desktop.line-scdn.net/win/new/LineInst.exe" -FileName "LineInst.exe" -Args "/S" -AppName "LINE"
|
|
}
|
|
} else {
|
|
Write-Host " [SKIP] LINE already installed"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[3/5] Installing Google Chrome"
|
|
if (-not (Test-AppInstalled -AppName "Chrome" -ProcessName "chrome")) {
|
|
if (-not (Install-ViaWinget -AppId "Google.Chrome" -AppName "Chrome")) {
|
|
Install-Manual -Url "https://dl.google.com/chrome/install/GoogleChromeStandaloneEnterprise64.msi" -FileName "ChromeSetup.msi" -Args "/quiet /norestart" -AppName "Chrome"
|
|
}
|
|
} else {
|
|
Write-Host " [SKIP] Chrome already installed"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[4/5] Installing 7-Zip"
|
|
if (-not (Test-AppInstalled -AppName "7-Zip" -ProcessName "7zFM")) {
|
|
if (-not (Install-ViaWinget -AppId "7zip.7zip" -AppName "7-Zip")) {
|
|
Install-Manual -Url "https://7-zip.org/a/7z2301-x64.msi" -FileName "7zip-setup.msi" -Args "/quiet /norestart" -AppName "7-Zip"
|
|
}
|
|
} else {
|
|
Write-Host " [SKIP] 7-Zip already installed"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[5/5] Installing Adobe Reader"
|
|
if (-not (Test-AppInstalled -AppName "Adobe" -ProcessName "AcroRd32")) {
|
|
if (-not (Install-ViaWinget -AppId "Adobe.Acrobat.Reader.64-bit" -AppName "Adobe Reader")) {
|
|
# Adobe Reader requires more complex download, try alternative
|
|
Write-Host " [!] Adobe Reader requires manual download from Adobe website"
|
|
Write-Host " Please visit: https://get.adobe.com/reader/"
|
|
Write-Host " Or try: winget install Adobe.Acrobat.Reader.64-bit"
|
|
}
|
|
} else {
|
|
Write-Host " [SKIP] Adobe Reader already installed"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "=== Installation Summary ==="
|
|
|
|
# Final verification
|
|
$apps = @(
|
|
@{Name="AnyDesk"; Process="AnyDesk"}
|
|
@{Name="LINE"; Process="LINE"}
|
|
@{Name="Chrome"; Process="chrome"}
|
|
@{Name="7-Zip"; Process="7zFM"}
|
|
@{Name="Adobe"; Process="AcroRd32"}
|
|
)
|
|
|
|
foreach ($app in $apps) {
|
|
$installed = Test-AppInstalled -AppName $app.Name -ProcessName $app.Process
|
|
if ($installed) {
|
|
Write-Host "[OK] $($app.Name) - Installed"
|
|
} else {
|
|
Write-Host "[!] $($app.Name) - Not detected (may need manual verification)"
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[*] Application installation process completed"
|
|
Write-Host "Note: Some applications may require restart to appear in Start Menu"
|
|
Write-Host "All applications will be available to all users on this computer" |