commit
74b76e88da
|
@ -213,26 +213,33 @@ function Install-WingetAutoUpdate{
|
|||
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
|
||||
Register-ScheduledTask -TaskName 'Winget-AutoUpdate-Notify' -InputObject $task -Force | Out-Null
|
||||
|
||||
# Install config file
|
||||
[xml]$ConfigXML = @"
|
||||
<?xml version="1.0"?>
|
||||
<app>
|
||||
<WAUautoupdate>$(!($DisableWAUAutoUpdate))</WAUautoupdate>
|
||||
<WAUprerelease>False</WAUprerelease>
|
||||
<UseWAUWhiteList>$UseWhiteList</UseWAUWhiteList>
|
||||
<NotificationLevel>$NotificationLevel</NotificationLevel>
|
||||
</app>
|
||||
"@
|
||||
$ConfigXML.Save("$WingetUpdatePath\config\config.xml")
|
||||
# Configure Reg Key
|
||||
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
|
||||
New-Item $regPath -Force
|
||||
New-ItemProperty $regPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force
|
||||
New-ItemProperty $regPath -Name DisplayVersion -Value 1.10.0 -Force
|
||||
New-ItemProperty $regPath -Name InstallLocation -Value $WingetUpdatePath -Force
|
||||
New-ItemProperty $regPath -Name UninstallString -Value "$WingetUpdatePath\Uninstall.bat" -Force
|
||||
New-ItemProperty $regPath -Name QuietUninstallString -Value "$WingetUpdatePath\Uninstall.bat" -Force
|
||||
New-ItemProperty $regPath -Name NoModify -Value 1 -Force
|
||||
New-ItemProperty $regPath -Name NoRepair -Value 1 -Force
|
||||
New-ItemProperty $regPath -Name VersionMajor -Value 1 -Force
|
||||
New-ItemProperty $regPath -Name VersionMinor -Value 10 -Force
|
||||
New-ItemProperty $regPath -Name Publisher -Value "Romanitho" -Force
|
||||
New-ItemProperty $regPath -Name URLInfoAbout -Value "https://github.com/Romanitho/Winget-AutoUpdate" -Force
|
||||
if ($DisableWAUAutoUpdate) {New-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Value 1 -Force}
|
||||
New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force
|
||||
if ($UseWhiteList) {New-ItemProperty $regPath -Name WAU_UseWhiteList -Value 1 -PropertyType DWord -Force}
|
||||
New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $NotificationLevel -Force
|
||||
|
||||
Write-host "`n WAU Installation succeeded!" -ForegroundColor Green
|
||||
Write-host "`nWAU Installation succeeded!" -ForegroundColor Green
|
||||
Start-sleep 1
|
||||
|
||||
#Run Winget ?
|
||||
Start-WingetAutoUpdate
|
||||
}
|
||||
catch{
|
||||
Write-host "`n WAU Installation failed! Run me with admin rights" -ForegroundColor Red
|
||||
Write-host "`nWAU Installation failed! Run me with admin rights" -ForegroundColor Red
|
||||
Start-sleep 1
|
||||
return $False
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<app>
|
||||
<name>Winget-AutoUpdate (WAU)</name>
|
||||
<version>1.10.0</version>
|
||||
<author>Romanitho</author>
|
||||
<info>https://github.com/Romanitho/Winget-AutoUpdate</info>
|
||||
</app>
|
|
@ -3,7 +3,7 @@
|
|||
function Get-WAUAvailableVersion {
|
||||
|
||||
#Get Github latest version
|
||||
if ($true -eq $WAUprerelease) {
|
||||
if ($WAUConfig.WAU_UpdatePrerelease -eq 1) {
|
||||
|
||||
#Get latest pre-release info
|
||||
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases'
|
||||
|
@ -16,6 +16,6 @@ function Get-WAUAvailableVersion {
|
|||
|
||||
}
|
||||
|
||||
$Script:WAUAvailableVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v","")
|
||||
return ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v","")
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
#Function to get WAU Configs
|
||||
|
||||
function Get-WAUConfig{
|
||||
|
||||
#Get config file
|
||||
[xml]$WAUConfig = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||
|
||||
#Check if WAU is configured for Black or White List
|
||||
if ($true -eq [System.Convert]::ToBoolean($WAUConfig.app.UseWAUWhiteList)){
|
||||
$Script:UseWhiteList = $true
|
||||
}
|
||||
else{
|
||||
$Script:UseWhiteList = $false
|
||||
}
|
||||
|
||||
#Get Notification Level
|
||||
if ($WAUConfig.app.NotificationLevel){
|
||||
$Script:NotificationLevel = $WAUConfig.app.NotificationLevel
|
||||
}
|
||||
else{
|
||||
#Default: Full
|
||||
$Script:NotificationLevel = "Full"
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#Function to get current WAU installed version
|
||||
|
||||
function Get-WAUCurrentVersion{
|
||||
|
||||
#Get current installed version
|
||||
[xml]$About = Get-Content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||
$Script:WAUCurrentVersion = $About.app.version
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
#Function to get WAU Update configurations
|
||||
|
||||
function Get-WAUUpdateStatus{
|
||||
|
||||
[xml]$UpdateStatus = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||
|
||||
#Check if AutoUpdate is enabled
|
||||
if ($true -eq [System.Convert]::ToBoolean($UpdateStatus.app.WAUautoupdate)){
|
||||
|
||||
Write-Log "WAU AutoUpdate is Enabled. Current version : $WAUCurrentVersion" "Green"
|
||||
$Script:WAUautoupdate = $true
|
||||
|
||||
#Check if pre-release versions are enabled
|
||||
if ($true -eq [System.Convert]::ToBoolean($UpdateStatus.app.WAUprerelease)){
|
||||
Write-Log "WAU AutoUpdate Pre-release versions is Enabled" "Cyan"
|
||||
$Script:WAUprerelease = $true
|
||||
}
|
||||
else{
|
||||
$Script:WAUprerelease = $false
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
Write-Log "WAU AutoUpdate is Disabled. Current version : $WAUCurrentVersion" "Grey"
|
||||
$Script:WAUautoupdate = $false
|
||||
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
|
||||
|
||||
if (($NotificationLevel -eq "Full") -or ($NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success")) {
|
||||
if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success")) {
|
||||
|
||||
#Add XML variables
|
||||
[xml]$ToastTemplate = @"
|
||||
|
@ -25,11 +25,11 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
|
|||
if ($currentPrincipal -eq $false){
|
||||
|
||||
#Save XML to File
|
||||
$ToastTemplateLocation = "$env:ProgramData\Winget-AutoUpdate\"
|
||||
$ToastTemplateLocation = "$env:ProgramData\Winget-AutoUpdate\config\"
|
||||
if (!(Test-Path $ToastTemplateLocation)){
|
||||
New-Item -ItemType Directory -Force -Path $ToastTemplateLocation
|
||||
}
|
||||
$ToastTemplate.Save("$ToastTemplateLocation\config\notif.xml")
|
||||
$ToastTemplate.Save("$ToastTemplateLocation\notif.xml")
|
||||
|
||||
#Run Notify scheduled task to notify conneted users
|
||||
Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue
|
||||
|
|
|
@ -38,10 +38,10 @@ function Update-WAU {
|
|||
Remove-Item -Path $ZipFile -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue
|
||||
|
||||
#Set new version to 'about.xml'
|
||||
[xml]$XMLconf = Get-content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||
$XMLconf.app.version = $WAUAvailableVersion
|
||||
$XMLconf.Save("$WorkingDir\config\about.xml")
|
||||
#Set new version to registry
|
||||
$WAUConfig | New-ItemProperty $regPath -Name DisplayVersion -Value $WAUAvailableVersion -Force
|
||||
$WAUConfig | New-ItemProperty $regPath -Name VersionMajor -Value ([version]$WAUAvailableVersion).Major -Force
|
||||
$WAUConfig | New-ItemProperty $regPath -Name VersionMinor -Value ([version]$WAUAvailableVersion).Minor -Force
|
||||
|
||||
#Send success Notif
|
||||
Write-Log "WAU Update completed." "Green"
|
||||
|
|
|
@ -18,7 +18,7 @@ if ([System.Security.Principal.WindowsIdentity]::GetCurrent().IsSystem) {
|
|||
}
|
||||
|
||||
#Get WAU Configurations
|
||||
Get-WAUConfig
|
||||
$Script:WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
|
||||
|
||||
#Get Notif Locale function
|
||||
Get-NotifLocale
|
||||
|
@ -30,13 +30,18 @@ if (Test-Network){
|
|||
|
||||
if ($TestWinget){
|
||||
#Get Current Version
|
||||
Get-WAUCurrentVersion
|
||||
#Check if WAU update feature is enabled
|
||||
Get-WAUUpdateStatus
|
||||
$WAUCurrentVersion = $WAUConfig.DisplayVersion
|
||||
Write-Log "WAU current version: $WAUCurrentVersion"
|
||||
#Check if WAU update feature is enabled or not
|
||||
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
|
||||
#If yes then check WAU update
|
||||
if ($true -eq $WAUautoupdate){
|
||||
if ($WAUDisableAutoUpdate -eq 1){
|
||||
Write-Log "WAU AutoUpdate is Disabled." "Grey"
|
||||
}
|
||||
else{
|
||||
Write-Log "WAU AutoUpdate is Enabled." "Green"
|
||||
#Get Available Version
|
||||
Get-WAUAvailableVersion
|
||||
$WAUAvailableVersion = Get-WAUAvailableVersion
|
||||
#Compare
|
||||
if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion){
|
||||
#If new version is available, update it
|
||||
|
@ -49,9 +54,10 @@ if (Test-Network){
|
|||
}
|
||||
|
||||
#Get White or Black list
|
||||
if ($UseWhiteList){
|
||||
if ($WAUConfig.WAU_UseWhiteList -eq 1){
|
||||
Write-Log "WAU uses White List config"
|
||||
$toUpdate = Get-IncludedApps
|
||||
$UseWhiteList = $true
|
||||
}
|
||||
else{
|
||||
Write-Log "WAU uses Black List config"
|
||||
|
@ -89,7 +95,7 @@ if (Test-Network){
|
|||
}
|
||||
}
|
||||
}
|
||||
#If Black List
|
||||
#If Black List or default
|
||||
else{
|
||||
#For each app, notify and update
|
||||
foreach ($app in $outdated){
|
||||
|
|
Loading…
Reference in New Issue