187 lines
6.1 KiB
PowerShell
187 lines
6.1 KiB
PowerShell
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
Write-Host "[*] Installing remaining applications with Windows Defender bypass"
|
|
Write-Host "Apps: AnyDesk, LINE, Adobe Reader"
|
|
Write-Host ""
|
|
|
|
# Check if running as administrator
|
|
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
if (-not $isAdmin) {
|
|
Write-Host "[!] ERROR: This script must be run as Administrator"
|
|
exit 1
|
|
}
|
|
|
|
$downloadFolder = "$env:TEMP\DirectAppInstalls"
|
|
New-Item -ItemType Directory -Force -Path $downloadFolder | Out-Null
|
|
|
|
# Function to temporarily disable Windows Defender
|
|
function Disable-WindowsDefender {
|
|
Write-Host "[*] Temporarily disabling Windows Defender real-time protection..."
|
|
try {
|
|
Set-MpPreference -DisableRealtimeMonitoring $true
|
|
Write-Host " [OK] Windows Defender real-time protection disabled"
|
|
return $true
|
|
} catch {
|
|
Write-Host " [!] Failed to disable Windows Defender: $($_.Exception.Message)"
|
|
Write-Host " Continuing with installation anyway..."
|
|
return $false
|
|
}
|
|
}
|
|
|
|
# Function to re-enable Windows Defender
|
|
function Enable-WindowsDefender {
|
|
Write-Host "[*] Re-enabling Windows Defender real-time protection..."
|
|
try {
|
|
Set-MpPreference -DisableRealtimeMonitoring $false
|
|
Write-Host " [OK] Windows Defender real-time protection re-enabled"
|
|
} catch {
|
|
Write-Host " [!] Failed to re-enable Windows Defender: $($_.Exception.Message)"
|
|
}
|
|
}
|
|
|
|
# Function to install application
|
|
function Install-DirectApp {
|
|
param(
|
|
[string]$Name,
|
|
[string]$Url,
|
|
[string]$FileName,
|
|
[string]$InstallArgs,
|
|
[int]$TimeoutMinutes = 5
|
|
)
|
|
|
|
Write-Host "Installing $Name..."
|
|
Write-Host " URL: $Url"
|
|
|
|
$downloadPath = Join-Path $downloadFolder $FileName
|
|
$success = $false
|
|
|
|
try {
|
|
# Download
|
|
Write-Host " Downloading..."
|
|
Invoke-WebRequest -Uri $Url -OutFile $downloadPath -UseBasicParsing -TimeoutSec 120
|
|
|
|
if (Test-Path $downloadPath) {
|
|
$fileSize = (Get-Item $downloadPath).Length / 1MB
|
|
Write-Host " Downloaded: $([math]::Round($fileSize, 2)) MB"
|
|
|
|
# Install
|
|
Write-Host " Installing with args: $InstallArgs"
|
|
|
|
if ($FileName.EndsWith(".msi")) {
|
|
$process = Start-Process -FilePath "msiexec" -ArgumentList "/i", $downloadPath, $InstallArgs -Wait -PassThru
|
|
} else {
|
|
$argList = $InstallArgs.Split(' ') + $downloadPath
|
|
$process = Start-Process -FilePath $downloadPath -ArgumentList $InstallArgs -Wait -PassThru -WindowStyle Hidden
|
|
}
|
|
|
|
Write-Host " Process exit code: $($process.ExitCode)"
|
|
|
|
if ($process.ExitCode -eq 0 -or $process.ExitCode -eq 3010) {
|
|
Write-Host " [OK] $Name installation completed successfully"
|
|
$success = $true
|
|
} else {
|
|
Write-Host " [!] $Name installation may have failed (exit code: $($process.ExitCode))"
|
|
# Some installers return non-zero codes even on success, so we'll verify later
|
|
}
|
|
|
|
} else {
|
|
Write-Host " [!] Download failed - file not found"
|
|
}
|
|
|
|
} catch {
|
|
Write-Host " [ERROR] $Name installation failed: $($_.Exception.Message)"
|
|
} finally {
|
|
# Clean up download
|
|
if (Test-Path $downloadPath) {
|
|
Remove-Item $downloadPath -Force -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
|
|
return $success
|
|
}
|
|
|
|
# Applications to install
|
|
$apps = @(
|
|
@{
|
|
Name = "AnyDesk"
|
|
Url = "https://download.anydesk.com/AnyDesk.msi"
|
|
FileName = "AnyDesk.msi"
|
|
InstallArgs = "/quiet /norestart"
|
|
},
|
|
@{
|
|
Name = "LINE"
|
|
Url = "https://desktop.line-scdn.net/win/new/LineInst.exe"
|
|
FileName = "LineInst.exe"
|
|
InstallArgs = "/S"
|
|
},
|
|
@{
|
|
Name = "Adobe Reader"
|
|
Url = "https://ardownload2.adobe.com/pub/adobe/reader/win/AcrobatDC/2300820555/AcroRdrDC2300820555_en_US.exe"
|
|
FileName = "AdobeReader.exe"
|
|
InstallArgs = "/sAll /rs /msi EULA_ACCEPT=YES"
|
|
}
|
|
)
|
|
|
|
Write-Host "=== Starting Installation Process ==="
|
|
Write-Host ""
|
|
|
|
# Disable Windows Defender
|
|
$defenderDisabled = Disable-WindowsDefender
|
|
|
|
$installedCount = 0
|
|
$totalApps = $apps.Count
|
|
|
|
try {
|
|
foreach ($app in $apps) {
|
|
Write-Host "[$($installedCount + 1)/$totalApps] $($app.Name)"
|
|
|
|
if (Install-DirectApp -Name $app.Name -Url $app.Url -FileName $app.FileName -InstallArgs $app.InstallArgs) {
|
|
$installedCount++
|
|
}
|
|
|
|
Write-Host ""
|
|
Start-Sleep -Seconds 3
|
|
}
|
|
|
|
} finally {
|
|
# Always re-enable Windows Defender
|
|
if ($defenderDisabled) {
|
|
Enable-WindowsDefender
|
|
}
|
|
}
|
|
|
|
# Clean up download folder
|
|
Remove-Item $downloadFolder -Recurse -Force -ErrorAction SilentlyContinue
|
|
|
|
Write-Host "=== Installation Summary ==="
|
|
Write-Host "Successfully installed: $installedCount / $totalApps applications"
|
|
Write-Host ""
|
|
|
|
# Final verification
|
|
Write-Host "=== Verification ==="
|
|
|
|
$verificationPaths = @(
|
|
@{Name="AnyDesk"; Paths=@("C:\Program Files (x86)\AnyDesk\AnyDesk.exe", "C:\Program Files\AnyDesk\AnyDesk.exe")},
|
|
@{Name="LINE"; Paths=@("C:\Users\$env:USERNAME\AppData\Local\LINE\bin\LineLauncher.exe", "C:\Program Files\LINE\bin\LineLauncher.exe")},
|
|
@{Name="Adobe Reader"; Paths=@("C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe", "C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe")}
|
|
)
|
|
|
|
foreach ($check in $verificationPaths) {
|
|
$found = $false
|
|
foreach ($path in $check.Paths) {
|
|
if (Test-Path $path) {
|
|
Write-Host "[OK] $($check.Name) - Found at $path"
|
|
$found = $true
|
|
break
|
|
}
|
|
}
|
|
if (-not $found) {
|
|
Write-Host "[!] $($check.Name) - Not found (may need restart or manual verification)"
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "Installation completed!"
|
|
Write-Host "Note: Some applications may require restart to appear in Start Menu"
|
|
Write-Host "Windows Defender real-time protection has been restored" |