Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module $env:SyncroModule -WarningAction SilentlyContinue
- $InstallIfMissing = $true
- $choco = "C:\Program Files\RepairTech\Syncro\kabuto_app_manager\choco.exe"
- function Find-IfInstalled( $program ) {
- $x86 = ((Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall") |
- Where-Object { $_.GetValue( "DisplayName" ) -like "$program" } ).Length -gt 0;
- $x64 = ((Get-ChildItem "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall") |
- Where-Object { $_.GetValue( "DisplayName" ) -like "$program" } ).Length -gt 0;
- return $x86 -or $x64;
- }
- # Check current install status
- if (Find-IfInstalled ('Adobe Acrobat Reader MUI')) {
- Write-Output "Adobe Acrobat Reader MUI already installed, exiting."
- Close-Rmm-Alert -Category "Task - Remove Adobe Reader and Reinstall MUI Version"
- exit 0
- }
- if (-not (Find-IfInstalled ('Adobe Acrobat Reader')) -and $InstallIfMissing -eq $false) {
- Write-Output "Adobe Acrobat Reader not installed and InstallIfMissing is set to false, exiting."
- exit 0
- }
- # Sleep if Windows Installer is busy
- while ((Get-Process | Where-Object Name -eq 'msiexec' | Group-Object -Property Name -NoElement).Count -gt 1) {
- Write-Output 'Waiting for Windows Installer availability...'
- Start-Sleep 30
- }
- Write-Output "Checking for Adobe Reader process..."
- $reader = Get-Process AcroRd32 -ErrorAction SilentlyContinue
- if ($reader) {
- # try gracefully first
- Write-Output "Closing Adobe Reader..."
- $reader.CloseMainWindow()
- # kill after five seconds
- Start-Sleep 5
- if (!$reader.HasExited) {
- $reader | Stop-Process -Force
- }
- }
- Write-Output "Removing Adobe Reader..."
- Start-Process -FilePath msiexec.exe -ArgumentList "/x {AC76BA86-7AD7-1033-7B44-AC0F074E4100} /qn" -Wait
- if (Find-IfInstalled ('Adobe Acrobat Reader MUI')) {
- Write-Output "Adobe Reader uninstall failed"
- Rmm-Alert -Category 'Task - Remove Adobe Reader and Reinstall MUI Version' -Body "Adobe Reader uninstall failed"
- exit 1
- }
- Write-Output "Installing Adobe Reader MUI..."
- &$choco install adobereader -y -f --no-progress
- if (Find-IfInstalled ('Adobe Acrobat Reader MUI')) {
- Write-Output "Adobe Reader MUI installed"
- Close-Rmm-Alert -Category "Task - Remove Adobe Reader and Reinstall MUI Version"
- exit 0
- }
- else {
- Write-Output "Adobe Reader MUI not found, install failed"
- Rmm-Alert -Category 'Task - Remove Adobe Reader and Reinstall MUI Version' -Body "Adobe Reader MUI not found, install failed"
- exit 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement