From a16313b367ed3d529cddab54768c18fa21b4b0d8 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 23 Apr 2023 17:00:25 +0200 Subject: [PATCH] Write-ToLog --- Winget-AutoUpdate/User-Run.ps1 | 7 +++++-- Winget-AutoUpdate/Winget-Upgrade.ps1 | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Winget-AutoUpdate/User-Run.ps1 b/Winget-AutoUpdate/User-Run.ps1 index 199e1f7..ff71dfb 100644 --- a/Winget-AutoUpdate/User-Run.ps1 +++ b/Winget-AutoUpdate/User-Run.ps1 @@ -21,7 +21,7 @@ https://github.com/Romanitho/Winget-AutoUpdate param( [Parameter(Mandatory = $False)] [Switch] $Logs = $false, [Parameter(Mandatory = $False)] [Switch] $Help = $false, - [Parameter(Mandatory = $False)] [String] $NotifApproved, + [Parameter(Mandatory = $False)] [String] $NotifApproved ) function Test-WAUisRunning { @@ -103,7 +103,10 @@ else { $MessageType = "success" $Message = $NotifLocale.local.outputs.output[9].message } - Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun + $IsUserApprovalEnable = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name WAU_UserApproval -ErrorAction SilentlyContinue).WAU_UserApproval + if ($IsUserApprovalEnable -ne "1"){ + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun + } } catch { #Check failed - Just send notification diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 81e35cb..dbba189 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -238,23 +238,23 @@ if (Test-Network) { #Ask user to approve, if configured if ($WAUConfig.WAU_UserApproval -eq 1){ - Write-Log "User Approval feature enabled." + Write-ToLog "User Approval feature enabled." #Check for approved tag $WAUNotifApproved = "$WorkingDir/Config/NotifApproved.txt" if (Test-Path $WAUNotifApproved) { - Write-Log "-> User approved notification." + Write-ToLog "-> User approved notification." Remove-Item $WAUNotifApproved -Force -Confirm:$false } else { $UserApprovalReturn = Invoke-UserApproval $outdated if ($UserApprovalReturn -eq 0){ - Write-Log "-> User approval requested. Waiting for user to approve available updates... Closing for now." + Write-ToLog "-> User approval requested. Waiting for user to approve available updates... Closing for now." #Closing job, waiting for user approval Exit 0 } else{ - Write-log "-> No update to request to user." + Write-ToLog "-> No update to request to user." } } }