Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires -Version 2.0
- # Refer to https://wiki.mozilla.org/Software_Update:Manually_Installing_a_MAR_file
- # Applies newest downloaded update from $OUTSIDE folder
- # I do very few checks, you should know what you're doing
- # Tested with http://archive.mozilla.org/pub/firefox/releases/58.0.2/update/win64/ru/
- # Greetings from ALTracer
- #
- # UAC elevating...
- If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
- { $arguments = "& '" + $myinvocation.mycommand.definition + "'"
- Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments
- break }
- # CHANGE YOUR DIRS
- $OUTSIDE = "D:\Install\ff"
- $APP = "C:\Program Files\Mozilla Firefox"
- # assuming current user has write access over there:
- Set-Location $OUTSIDE
- $latestmar = Get-ChildItem -Path $OUTSIDE -Name *.mar | Sort-Object LastWriteTime -Descending | Select-Object -First 1
- Copy-Item -Force $latestmar update.mar
- $latestasc = Get-ChildItem -Path $OUTSIDE -Name *.asc | Sort-Object LastWriteTime -Descending | Select-Object -First 1
- Copy-Item -Force $latestasc update.mar.asc
- Copy-Item -Force $APP\updater.exe updater.exe
- Copy-Item -Force $APP\updater.ini updater.ini
- # now we must be UAC elevated
- Set-Location $APP
- Start-Process -Wait -FilePath $OUTSIDE\updater.exe -ArgumentList "$OUTSIDE `"$APP`" `"$APP`""
- $status = Get-Content $OUTSIDE\update.status
- if ($status -eq "succeeded")
- { Remove-Item $APP\uninstall\uninstall.update
- Copy-Item -Force $OUTSIDE\update.log $APP\uninstall\uninstall.update
- Start-Process -Wait -FilePath "`"$APP\uninstall\helper.exe`"" -ArgumentList "/PostUpdate"
- Read-Host "Updated, I guess"}
- else
- { type $OUTSIDE\update.status
- Read-Host "Error applying update! Check update.log" }
- # cleanup
- Set-Location $OUTSIDE
- Remove-Item updater.ini
- Remove-Item updater.exe
- Remove-Item update.mar
- Remove-Item update.asc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement