Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module $env:SyncroModule -WarningAction SilentlyContinue
- $chocopath = "$env:allusersprofile\chocolatey\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;
- }
- Write-Output "Checking for Choco..."
- if (-not (Test-Path "$chocopath")) {
- Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
- if (-not (Test-Path "$chocopath")) {
- Write-Output "Chocolatey install failed"
- Rmm-Alert -Category 'Remove Adobe Reader and Reinstall MUI Version' -Body 'Chocolatey install failed'
- exit 1
- }
- }
- 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 DC')) {
- Write-Output "Adobe Reader uninstall failed"
- Rmm-Alert -Category 'Remove Adobe Reader and Reinstall MUI Version' -Body "Adobe Reader uninstall failed"
- exit 1
- }
- Write-Output "Installing Adobe Reader MUI..."
- Start-Process -FilePath "$chocopath" -ArgumentList "install adobereader -y -f" -Wait
- if (Find-IfInstalled ('Adobe Acrobat Reader DC MUI')) {
- Write-Output "Adobe Reader MUI installed"
- exit 0
- }
- else {
- Write-Output "Adobe Reader MUI not found, install failed"
- Rmm-Alert -Category '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