commit
441eed57d0
|
@ -14,7 +14,10 @@ Install Winget-AutoUpdate and prerequisites silently
|
||||||
Specify Winget-AutoUpdate installation localtion. Default: C:\ProgramData\Winget-AutoUpdate\
|
Specify Winget-AutoUpdate installation localtion. Default: C:\ProgramData\Winget-AutoUpdate\
|
||||||
|
|
||||||
.PARAMETER DoNotUpdate
|
.PARAMETER DoNotUpdate
|
||||||
Do not run Winget-autoupdate after installation. By default, Winget-AutoUpdate is run just after installation.
|
Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate is run just after installation.
|
||||||
|
|
||||||
|
.PARAMETER DisableWAUAutoUpdate
|
||||||
|
Disable Winget-AutoUpdate update checking. By default, WAU auto update if new version is available on Github.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
.\winget-install-and-update.ps1 -Silent -DoNotUpdate
|
.\winget-install-and-update.ps1 -Silent -DoNotUpdate
|
||||||
|
@ -24,7 +27,8 @@ Do not run Winget-autoupdate after installation. By default, Winget-AutoUpdate i
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$False)] [Alias('S')] [Switch] $Silent = $false,
|
[Parameter(Mandatory=$False)] [Alias('S')] [Switch] $Silent = $false,
|
||||||
[Parameter(Mandatory=$False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate",
|
[Parameter(Mandatory=$False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate",
|
||||||
[Parameter(Mandatory=$False)] [Switch] $DoNotUpdate = $false
|
[Parameter(Mandatory=$False)] [Switch] $DoNotUpdate = $false,
|
||||||
|
[Parameter(Mandatory=$False)] [Switch] $DisableWAUAutoUpdate = $false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,6 +121,15 @@ function Install-WingetAutoUpdate{
|
||||||
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
|
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
|
||||||
Register-ScheduledTask -TaskName 'Winget-AutoUpdate-Notify' -InputObject $task -Force
|
Register-ScheduledTask -TaskName 'Winget-AutoUpdate-Notify' -InputObject $task -Force
|
||||||
|
|
||||||
|
# Install config file
|
||||||
|
[xml]$ConfigXML = @"
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<app>
|
||||||
|
<WAUautoupdate>$(!($DisableWAUAutoUpdate))</WAUautoupdate>
|
||||||
|
</app>
|
||||||
|
"@
|
||||||
|
$ConfigXML.Save("$WingetUpdatePath\config\config.xml")
|
||||||
|
|
||||||
Write-host "`nInstallation succeeded!" -ForegroundColor Green
|
Write-host "`nInstallation succeeded!" -ForegroundColor Green
|
||||||
Start-sleep 1
|
Start-sleep 1
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<app>
|
||||||
|
<name>Winget-AutoUpdate (WAU)</name>
|
||||||
|
<version>1.4.0</version>
|
||||||
|
<author>Romanitho</author>
|
||||||
|
<info>https://github.com/Romanitho/Winget-AutoUpdate</info>
|
||||||
|
</app>
|
|
@ -2,7 +2,7 @@
|
||||||
<outputs>
|
<outputs>
|
||||||
<output id="0">
|
<output id="0">
|
||||||
<!--Check network connection-->
|
<!--Check network connection-->
|
||||||
<title>Prüfen Sie Ihre Internet Verbindung</title>
|
<title>Prüfen Sie Ihre Internet Verbindung.</title>
|
||||||
<!--Unable to check for software updates at this time!-->
|
<!--Unable to check for software updates at this time!-->
|
||||||
<message>Es konnte nicht nach Updates gesucht werden!</message>
|
<message>Es konnte nicht nach Updates gesucht werden!</message>
|
||||||
</output>
|
</output>
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
<outputs>
|
<outputs>
|
||||||
<output id="0">
|
<output id="0">
|
||||||
<!--Check network connection-->
|
<!--Check network connection-->
|
||||||
<title>Check network connection</title>
|
<title>Check network connection.</title>
|
||||||
<!--Unable to check for software updates at this time!-->
|
<!--Unable to check for software updates at this time!-->
|
||||||
<message>Unable to check for software updates at this time!</message>
|
<message>Unable to check for software updates at this time!</message>
|
||||||
</output>
|
</output>
|
||||||
<output id="1">
|
<output id="1">
|
||||||
<!--No internet connction-->
|
<!--No internet connction-->
|
||||||
<title>No internet connction!</title>
|
<title>No internet connction.</title>
|
||||||
<!--Updates could not be verified-->
|
<!--Updates could not be verified-->
|
||||||
<message>Updates could not be verified.</message>
|
<message>Updates could not be verified.</message>
|
||||||
</output>
|
</output>
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
<outputs>
|
<outputs>
|
||||||
<output id="0">
|
<output id="0">
|
||||||
<!--Check network connection-->
|
<!--Check network connection-->
|
||||||
<title>Vérifiez votre connexion réseau</title>
|
<title>Vérifiez votre connexion réseau.</title>
|
||||||
<!--Unable to check for software updates at this time!-->
|
<!--Unable to check for software updates at this time!-->
|
||||||
<message>Impossible de vérifier les mises à jours logicielles pour le moment !</message>
|
<message>Impossible de vérifier les mises à jours logicielles pour le moment !</message>
|
||||||
</output>
|
</output>
|
||||||
<output id="1">
|
<output id="1">
|
||||||
<!--No internet connction-->
|
<!--No internet connction-->
|
||||||
<title>Aucune connexion réseau</title>
|
<title>Aucune connexion réseau.</title>
|
||||||
<!--Updates could not be verified-->
|
<!--Updates could not be verified-->
|
||||||
<message>Les mises à jour logicielles n'ont pas pu être vérifiées !</message>
|
<message>Les mises à jour logicielles n'ont pas pu être vérifiées !</message>
|
||||||
</output>
|
</output>
|
||||||
|
|
|
@ -57,7 +57,7 @@ function Write-Log ($LogMsg,$LogColor = "White") {
|
||||||
|
|
||||||
function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
|
function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
|
||||||
|
|
||||||
#Add XML variables
|
#Add XML variables
|
||||||
[xml]$ToastTemplate = @"
|
[xml]$ToastTemplate = @"
|
||||||
<toast launch="ms-get-started://redirect?id=apps_action">
|
<toast launch="ms-get-started://redirect?id=apps_action">
|
||||||
<visual>
|
<visual>
|
||||||
|
@ -228,6 +228,103 @@ function Get-ExcludedApps{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Start-WAUUpdateCheck{
|
||||||
|
#Get AutoUpdate status
|
||||||
|
[xml]$UpdateStatus = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||||
|
$AutoUpdateStatus = $UpdateStatus.app.autoupdate
|
||||||
|
|
||||||
|
#Check if AutoUpdate is enabled
|
||||||
|
if ($AutoUpdateStatus -eq $false){
|
||||||
|
Write-Log "WAU Current version: $CurrentVersion. AutoUpdate is disabled." "Cyan"
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
#If enabled, check online available version
|
||||||
|
else{
|
||||||
|
#Get Github latest version
|
||||||
|
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest'
|
||||||
|
$LatestVersion = (Invoke-WebRequest $WAUurl | ConvertFrom-Json)[0].tag_name
|
||||||
|
[version]$AvailableVersion = $LatestVersion.Replace("v","")
|
||||||
|
|
||||||
|
#Get current installed version
|
||||||
|
[xml]$About = Get-Content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||||
|
[version]$CurrentVersion = $About.app.version
|
||||||
|
|
||||||
|
#If newer version is avalable, return $True
|
||||||
|
if ($AvailableVersion -gt $CurrentVersion){
|
||||||
|
Write-Log "WAU Current version: $CurrentVersion. Version $AvailableVersion is available." "Yellow"
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Write-Log "WAU Current version: $CurrentVersion. Up to date." "Green"
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Update-WAU{
|
||||||
|
#Get WAU Github latest version
|
||||||
|
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest'
|
||||||
|
$LatestVersion = (Invoke-WebRequest $WAUurl | ConvertFrom-Json)[0].tag_name
|
||||||
|
|
||||||
|
#Send available update notification
|
||||||
|
$Title = $NotifLocale.local.outputs.output[2].title -f "Winget-AutoUpdate"
|
||||||
|
$Message = $NotifLocale.local.outputs.output[2].message -f $CurrentVersion, $LatestVersion
|
||||||
|
$MessageType = "info"
|
||||||
|
$Balise = "Winget-AutoUpdate"
|
||||||
|
Start-NotifTask $Title $Message $MessageType $Balise
|
||||||
|
|
||||||
|
#Run WAU update
|
||||||
|
try{
|
||||||
|
#Force to create a zip file
|
||||||
|
$ZipFile = "$WorkingDir\WAU_update.zip"
|
||||||
|
New-Item $ZipFile -ItemType File -Force | Out-Null
|
||||||
|
|
||||||
|
#Download the zip
|
||||||
|
Write-Log "Starting downloading the GitHub Repository"
|
||||||
|
Invoke-RestMethod -Uri "$($WAUurl)/zipball/$($LatestVersion)" -OutFile $ZipFile
|
||||||
|
Write-Log 'Download finished'
|
||||||
|
|
||||||
|
#Extract Zip File
|
||||||
|
Write-Log "Starting unzipping the WAU GitHub Repository"
|
||||||
|
$location = "$WorkingDir\WAU_update"
|
||||||
|
Expand-Archive -Path $ZipFile -DestinationPath $location -Force
|
||||||
|
Get-ChildItem -Path $location -Recurse | Unblock-File
|
||||||
|
Write-Log "Unzip finished"
|
||||||
|
$TempPath = Resolve-Path "$location\Romanitho-Winget-AutoUpdate*\Winget-AutoUpdate\"
|
||||||
|
Copy-Item -Path "$TempPath\*" -Destination ".\" -Recurse -Force
|
||||||
|
|
||||||
|
#Remove update zip file
|
||||||
|
Write-Log "Cleaning temp files"
|
||||||
|
Remove-Item -Path $ZipFile -Force -ErrorAction SilentlyContinue
|
||||||
|
#Remove update folder
|
||||||
|
Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
#Set new version to conf.xml
|
||||||
|
[xml]$XMLconf = Get-content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||||
|
$XMLconf.app.version = $LatestVersion.Replace("v","")
|
||||||
|
$XMLconf.Save("$WorkingDir\config\about.xml")
|
||||||
|
|
||||||
|
#Send success Notif
|
||||||
|
$Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate"
|
||||||
|
$Message = $NotifLocale.local.outputs.output[3].message -f $LatestVersion
|
||||||
|
$MessageType = "success"
|
||||||
|
$Balise = "Winget-AutoUpdate"
|
||||||
|
Start-NotifTask $Title $Message $MessageType $Balise
|
||||||
|
|
||||||
|
#Rerun with newer version
|
||||||
|
Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
catch{
|
||||||
|
#Send Error Notif
|
||||||
|
$Title = $NotifLocale.local.outputs.output[4].title -f "Winget-AutoUpdate"
|
||||||
|
$Message = $NotifLocale.local.outputs.output[4].message
|
||||||
|
$MessageType = "error"
|
||||||
|
$Balise = "Winget-AutoUpdate"
|
||||||
|
Start-NotifTask $Title $Message $MessageType $Balise
|
||||||
|
Write-Log "WAU Update failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<# MAIN #>
|
<# MAIN #>
|
||||||
|
|
||||||
|
@ -236,6 +333,12 @@ Init
|
||||||
|
|
||||||
#Check network connectivity
|
#Check network connectivity
|
||||||
if (Test-Network){
|
if (Test-Network){
|
||||||
|
#Check if WAU is up to date
|
||||||
|
$CheckWAUupdate = Start-WAUUpdateCheck
|
||||||
|
#If AutoUpdate is enabled and Update is avalaible, then run WAU update
|
||||||
|
if ($CheckWAUupdate){
|
||||||
|
Update-WAU
|
||||||
|
}
|
||||||
|
|
||||||
#Get exclude apps list
|
#Get exclude apps list
|
||||||
$toSkip = Get-ExcludedApps
|
$toSkip = Get-ExcludedApps
|
||||||
|
|
Loading…
Reference in New Issue