Advertisement
Guest User

install

a guest
Oct 10th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Import-Module $env:SyncroModule -WarningAction SilentlyContinue
  2.  
  3. $chocopath = "$env:allusersprofile\chocolatey\choco.exe"
  4.  
  5. function Find-IfInstalled( $program ) {
  6.     $x86 = ((Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall") |
  7.         Where-Object { $_.GetValue( "DisplayName" ) -like "$program" } ).Length -gt 0;
  8.     $x64 = ((Get-ChildItem "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall") |
  9.         Where-Object { $_.GetValue( "DisplayName" ) -like "$program" } ).Length -gt 0;
  10.     return $x86 -or $x64;
  11. }
  12.  
  13. Write-Output "Checking for Choco..."
  14. if (-not (Test-Path "$chocopath")) {
  15.     Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
  16.     if (-not (Test-Path "$chocopath")) {
  17.         Write-Output "Chocolatey install failed"
  18.         Rmm-Alert -Category 'Remove Adobe Reader and Reinstall MUI Version' -Body 'Chocolatey install failed'
  19.         exit 1
  20.     }
  21. }
  22.  
  23. Write-Output "Checking for Adobe Reader process..."
  24. $reader = Get-Process AcroRd32 -ErrorAction SilentlyContinue
  25. if ($reader) {
  26.     # try gracefully first
  27.     Write-Output "Closing Adobe Reader..."
  28.     $reader.CloseMainWindow()
  29.     # kill after five seconds
  30.     Start-Sleep 5
  31.     if (!$reader.HasExited) {
  32.         $reader | Stop-Process -Force
  33.     }
  34. }
  35.  
  36. Write-Output "Removing Adobe Reader..."
  37. Start-Process -FilePath msiexec.exe -ArgumentList "/x {AC76BA86-7AD7-1033-7B44-AC0F074E4100} /qn" -Wait
  38. if (Find-IfInstalled ('Adobe Acrobat Reader DC')) {
  39.     Write-Output "Adobe Reader uninstall failed"
  40.     Rmm-Alert -Category 'Remove Adobe Reader and Reinstall MUI Version' -Body "Adobe Reader uninstall failed"
  41.     exit 1
  42. }
  43.  
  44. Write-Output "Installing Adobe Reader MUI..."
  45. Start-Process -FilePath "$chocopath" -ArgumentList "install adobereader -y -f" -Wait
  46. if (Find-IfInstalled ('Adobe Acrobat Reader DC MUI')) {
  47.     Write-Output "Adobe Reader MUI installed"
  48.     exit 0
  49. }
  50. else {
  51.     Write-Output "Adobe Reader MUI not found, install failed"
  52.     Rmm-Alert -Category 'Remove Adobe Reader and Reinstall MUI Version' -Body "Adobe Reader MUI not found, install failed"
  53.     exit 1
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement