commit
74b76e88da
|
@ -213,26 +213,33 @@ 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 | Out-Null
|
Register-ScheduledTask -TaskName 'Winget-AutoUpdate-Notify' -InputObject $task -Force | Out-Null
|
||||||
|
|
||||||
# Install config file
|
# Configure Reg Key
|
||||||
[xml]$ConfigXML = @"
|
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
|
||||||
<?xml version="1.0"?>
|
New-Item $regPath -Force
|
||||||
<app>
|
New-ItemProperty $regPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force
|
||||||
<WAUautoupdate>$(!($DisableWAUAutoUpdate))</WAUautoupdate>
|
New-ItemProperty $regPath -Name DisplayVersion -Value 1.10.0 -Force
|
||||||
<WAUprerelease>False</WAUprerelease>
|
New-ItemProperty $regPath -Name InstallLocation -Value $WingetUpdatePath -Force
|
||||||
<UseWAUWhiteList>$UseWhiteList</UseWAUWhiteList>
|
New-ItemProperty $regPath -Name UninstallString -Value "$WingetUpdatePath\Uninstall.bat" -Force
|
||||||
<NotificationLevel>$NotificationLevel</NotificationLevel>
|
New-ItemProperty $regPath -Name QuietUninstallString -Value "$WingetUpdatePath\Uninstall.bat" -Force
|
||||||
</app>
|
New-ItemProperty $regPath -Name NoModify -Value 1 -Force
|
||||||
"@
|
New-ItemProperty $regPath -Name NoRepair -Value 1 -Force
|
||||||
$ConfigXML.Save("$WingetUpdatePath\config\config.xml")
|
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
|
Start-sleep 1
|
||||||
|
|
||||||
#Run Winget ?
|
#Run Winget ?
|
||||||
Start-WingetAutoUpdate
|
Start-WingetAutoUpdate
|
||||||
}
|
}
|
||||||
catch{
|
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
|
Start-sleep 1
|
||||||
return $False
|
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 {
|
function Get-WAUAvailableVersion {
|
||||||
|
|
||||||
#Get Github latest version
|
#Get Github latest version
|
||||||
if ($true -eq $WAUprerelease) {
|
if ($WAUConfig.WAU_UpdatePrerelease -eq 1) {
|
||||||
|
|
||||||
#Get latest pre-release info
|
#Get latest pre-release info
|
||||||
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases'
|
$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) {
|
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
|
#Add XML variables
|
||||||
[xml]$ToastTemplate = @"
|
[xml]$ToastTemplate = @"
|
||||||
|
@ -25,11 +25,11 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
|
||||||
if ($currentPrincipal -eq $false){
|
if ($currentPrincipal -eq $false){
|
||||||
|
|
||||||
#Save XML to File
|
#Save XML to File
|
||||||
$ToastTemplateLocation = "$env:ProgramData\Winget-AutoUpdate\"
|
$ToastTemplateLocation = "$env:ProgramData\Winget-AutoUpdate\config\"
|
||||||
if (!(Test-Path $ToastTemplateLocation)){
|
if (!(Test-Path $ToastTemplateLocation)){
|
||||||
New-Item -ItemType Directory -Force -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
|
#Run Notify scheduled task to notify conneted users
|
||||||
Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue
|
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 $ZipFile -Force -ErrorAction SilentlyContinue
|
||||||
Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue
|
Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
#Set new version to 'about.xml'
|
#Set new version to registry
|
||||||
[xml]$XMLconf = Get-content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
$WAUConfig | New-ItemProperty $regPath -Name DisplayVersion -Value $WAUAvailableVersion -Force
|
||||||
$XMLconf.app.version = $WAUAvailableVersion
|
$WAUConfig | New-ItemProperty $regPath -Name VersionMajor -Value ([version]$WAUAvailableVersion).Major -Force
|
||||||
$XMLconf.Save("$WorkingDir\config\about.xml")
|
$WAUConfig | New-ItemProperty $regPath -Name VersionMinor -Value ([version]$WAUAvailableVersion).Minor -Force
|
||||||
|
|
||||||
#Send success Notif
|
#Send success Notif
|
||||||
Write-Log "WAU Update completed." "Green"
|
Write-Log "WAU Update completed." "Green"
|
||||||
|
|
|
@ -18,7 +18,7 @@ if ([System.Security.Principal.WindowsIdentity]::GetCurrent().IsSystem) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get WAU Configurations
|
#Get WAU Configurations
|
||||||
Get-WAUConfig
|
$Script:WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
|
||||||
|
|
||||||
#Get Notif Locale function
|
#Get Notif Locale function
|
||||||
Get-NotifLocale
|
Get-NotifLocale
|
||||||
|
@ -30,13 +30,18 @@ if (Test-Network){
|
||||||
|
|
||||||
if ($TestWinget){
|
if ($TestWinget){
|
||||||
#Get Current Version
|
#Get Current Version
|
||||||
Get-WAUCurrentVersion
|
$WAUCurrentVersion = $WAUConfig.DisplayVersion
|
||||||
#Check if WAU update feature is enabled
|
Write-Log "WAU current version: $WAUCurrentVersion"
|
||||||
Get-WAUUpdateStatus
|
#Check if WAU update feature is enabled or not
|
||||||
|
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
|
||||||
#If yes then check WAU update
|
#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 Available Version
|
||||||
Get-WAUAvailableVersion
|
$WAUAvailableVersion = Get-WAUAvailableVersion
|
||||||
#Compare
|
#Compare
|
||||||
if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion){
|
if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion){
|
||||||
#If new version is available, update it
|
#If new version is available, update it
|
||||||
|
@ -49,9 +54,10 @@ if (Test-Network){
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get White or Black list
|
#Get White or Black list
|
||||||
if ($UseWhiteList){
|
if ($WAUConfig.WAU_UseWhiteList -eq 1){
|
||||||
Write-Log "WAU uses White List config"
|
Write-Log "WAU uses White List config"
|
||||||
$toUpdate = Get-IncludedApps
|
$toUpdate = Get-IncludedApps
|
||||||
|
$UseWhiteList = $true
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Write-Log "WAU uses Black List config"
|
Write-Log "WAU uses Black List config"
|
||||||
|
@ -89,7 +95,7 @@ if (Test-Network){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#If Black List
|
#If Black List or default
|
||||||
else{
|
else{
|
||||||
#For each app, notify and update
|
#For each app, notify and update
|
||||||
foreach ($app in $outdated){
|
foreach ($app in $outdated){
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
@echo off
|
@echo off
|
||||||
powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file """%~dp0Winget-AutoUpdate-Install.ps1"" -UpdatesAtLogon'" -Verb RunAs
|
powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file """%~dp0Winget-AutoUpdate-Install.ps1"" -UpdatesAtLogon'" -Verb RunAs
|
Loading…
Reference in New Issue