Parameters, README, and fixes

pull/257/head
KnifMelti 2023-01-13 03:33:00 +01:00
parent 2fe4baec0a
commit bc7dd12a60
4 changed files with 46 additions and 4 deletions

View File

@ -73,6 +73,16 @@ You can run the `Winget-AutoUpdate-Install.ps1` script with parameters :
**-Silent**
Install Winget-AutoUpdate and prerequisites silently.
**-MaxLogFiles**
Specify number of allowed log files.
Default is 3 of 0-99:
Setting MaxLogFiles to 0 don't delete any old archived log files.
Setting it to 1 keeps the original one and just let it grow.
**-MaxLogSize**
Specify the size of the log file in bytes before rotating.
Default is 1048576 = 1 MB
**-WingetUpdatePath**
Specify Winget-AutoUpdate installation location. Default: `C:\ProgramData\Winget-AutoUpdate` (Recommended to leave default).

View File

@ -10,6 +10,12 @@ https://github.com/Romanitho/Winget-AutoUpdate
.PARAMETER Silent
Install Winget-AutoUpdate and prerequisites silently
.PARAMETER MaxLogFiles
Specify number of allowed log files (Default is 3 of 0-99: Setting MaxLogFiles to 0 don't delete any old archived log files, 1 keeps the original one and just let it grow)
.PARAMETER MaxLogSize
Specify the size of the log file in bytes before rotating. (Default is 1048576 = 1 MB)
.PARAMETER WingetUpdatePath
Specify Winget-AutoUpdate installation localtion. Default: C:\ProgramData\Winget-AutoUpdate\
@ -62,7 +68,7 @@ Install WAU with system and user context executions
Configure WAU to bypass the Black/White list when run in user context
.EXAMPLE
.\Winget-AutoUpdate-Install.ps1 -Silent -DoNotUpdate
.\Winget-AutoUpdate-Install.ps1 -Silent -DoNotUpdate -MaxLogFiles 4 -MaxLogSize 2097152
.EXAMPLE
.\Winget-AutoUpdate-Install.ps1 -Silent -UseWhiteList
@ -100,7 +106,9 @@ param(
[Parameter(Mandatory = $False)] [ValidateSet("Daily", "BiDaily", "Weekly", "BiWeekly", "Monthly", "Never")] [String] $UpdatesInterval = "Daily",
[Parameter(Mandatory = $False)] [DateTime] $UpdatesAtTime = ("06am"),
[Parameter(Mandatory = $False)] [Switch] $BypassListForUsers = $false,
[Parameter(Mandatory = $False)] [Switch] $InstallUserContext = $false
[Parameter(Mandatory = $False)] [Switch] $InstallUserContext = $false,
[Parameter(Mandatory = $False)] [ValidateRange(0,99)] [int32] $MaxLogFiles = 3,
[Parameter(Mandatory = $False)] [int64] $MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB
)
<# APP INFO #>
@ -337,6 +345,8 @@ function Install-WingetAutoUpdate {
New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $NotificationLevel -Force | Out-Null
New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force | Out-Null
New-ItemProperty $regPath -Name WAU_PostUpdateActions -Value 0 -PropertyType DWord -Force | Out-Null
New-ItemProperty $regPath -Name WAU_MaxLogFiles -Value $MaxLogFiles -PropertyType DWord -Force | Out-Null
New-ItemProperty $regPath -Name WAU_MaxLogSize -Value $MaxLogSize -PropertyType DWord -Force | Out-Null
if ($DisableWAUAutoUpdate) {
New-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Value 1 -Force | Out-Null
}

View File

@ -43,6 +43,16 @@ function Invoke-PostUpdateActions {
Write-Log "-> Notification level setting was missing. Fixed with 'Full' option."
}
#Set WAU_MaxLogFiles/WAU_MaxLogSize if not set
$MaxLogFiles = Get-ItemProperty $regPath -Name WAU_MaxLogFiles -ErrorAction SilentlyContinue
if (!$MaxLogFiles) {
New-ItemProperty $regPath -Name WAU_MaxLogFiles -Value 3 -PropertyType DWord -Force | Out-Null
New-ItemProperty $regPath -Name WAU_MaxLogSize -Value 1048576 -PropertyType DWord -Force | Out-Null
#log
Write-Log "-> MaxLogFiles/MaxLogSize setting was missing. Fixed with 3/1048576 (in bytes, default is 1048576 = 1 MB)."
}
#Convert about.xml if exists (previous WAU versions) to reg
$WAUAboutPath = "$WorkingDir\config\about.xml"
if (test-path $WAUAboutPath) {

View File

@ -6,10 +6,22 @@ function Start-Init {
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
# Maximum number of log files to keep. Default is 3. Setting MaxLogFiles to 0 will keep all log files.
[int32] $MaxLogFiles = 3
$MaxLogFiles = Get-ItemPropertyvalue -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate -Name "WAU_MaxLogFiles" -ErrorAction SilentlyContinue
if ($null = $MaxLogFiles) {
[int32] $MaxLogFiles = 3
}
else {
[int32] $MaxLogFiles = $MaxLogFiles
}
# Maximum size of log file.
[int64] $MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB
$MaxLogSize = Get-ItemPropertyvalue -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate -Name "WAU_MaxLogSize" -ErrorAction SilentlyContinue
if (!$MaxLogSize) {
[int64] $MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB
}
else {
[int64] $MaxLogSize = $MaxLogSize
}
#Log Header
$Log = "`n##################################################`n# CHECK FOR APP UPDATES - $(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern)`n##################################################"