Advertisement
ALTracer

Firefox (differential) MAR updater

Jan 30th, 2018
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Requires -Version 2.0
  2. # Refer to https://wiki.mozilla.org/Software_Update:Manually_Installing_a_MAR_file
  3. # Applies newest downloaded update from $OUTSIDE folder
  4. # I do very few checks, you should know what you're doing
  5. # Tested with http://archive.mozilla.org/pub/firefox/releases/58.0.2/update/win64/ru/
  6. # Greetings from ALTracer
  7. #
  8. # UAC elevating...
  9. If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
  10. { $arguments = "& '" + $myinvocation.mycommand.definition + "'"
  11.   Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments
  12.   break }
  13. # CHANGE YOUR DIRS
  14. $OUTSIDE = "D:\Install\ff"
  15. $APP = "C:\Program Files\Mozilla Firefox"
  16. # assuming current user has write access over there:
  17. Set-Location $OUTSIDE
  18. $latestmar = Get-ChildItem -Path $OUTSIDE -Name *.mar | Sort-Object LastWriteTime -Descending | Select-Object -First 1
  19. Copy-Item -Force $latestmar update.mar
  20. $latestasc = Get-ChildItem -Path $OUTSIDE -Name *.asc | Sort-Object LastWriteTime -Descending | Select-Object -First 1
  21. Copy-Item -Force $latestasc update.mar.asc
  22. Copy-Item -Force $APP\updater.exe updater.exe
  23. Copy-Item -Force $APP\updater.ini updater.ini
  24. # now we must be UAC elevated
  25. Set-Location $APP
  26. Start-Process -Wait -FilePath $OUTSIDE\updater.exe -ArgumentList "$OUTSIDE `"$APP`" `"$APP`""
  27. $status = Get-Content $OUTSIDE\update.status
  28. if ($status -eq "succeeded")
  29. { Remove-Item $APP\uninstall\uninstall.update
  30.   Copy-Item -Force $OUTSIDE\update.log $APP\uninstall\uninstall.update
  31.   Start-Process -Wait -FilePath "`"$APP\uninstall\helper.exe`"" -ArgumentList "/PostUpdate"
  32.   Read-Host "Updated, I guess"}
  33. else
  34. { type $OUTSIDE\update.status
  35.   Read-Host "Error applying update! Check update.log" }
  36. # cleanup
  37. Set-Location $OUTSIDE
  38. Remove-Item updater.ini
  39. Remove-Item updater.exe
  40. Remove-Item update.mar
  41. Remove-Item update.asc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement