From 840fad03da980effe6c07abf967c9f66692c2ece Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Oct 2022 22:07:47 +0200 Subject: [PATCH 1/3] Set ACL if log file exists --- Winget-AutoUpdate-Install.ps1 | 13 +++++++++++++ install.bat | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 990595b..ac9d00c 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -337,6 +337,19 @@ function Install-WingetAutoUpdate { New-ItemProperty $regPath -Name WAU_BypassListForUsers -Value 1 -PropertyType DWord -Force | Out-Null } + #Set ACL for users on logfile + $LogFile = "$WingetUpdatePath\logs\updates.log" + if (test-path $LogFile){ + $NewAcl = Get-Acl -Path $LogFile + $identity = New-Object System.Security.Principal.SecurityIdentifier S-1-5-11 + $fileSystemRights = "Modify" + $type = "Allow" + $fileSystemAccessRuleArgumentList = $identity, $fileSystemRights, $type + $fileSystemAccessRule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $fileSystemAccessRuleArgumentList + $NewAcl.SetAccessRule($fileSystemAccessRule) + Set-Acl -Path $LogFile -AclObject $NewAcl + } + #Create Shortcuts if ($StartMenuShortcut) { if (!(Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) { diff --git a/install.bat b/install.bat index 6fcd9a2..3fd1e86 100644 --- a/install.bat +++ b/install.bat @@ -1,2 +1,5 @@ @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 \ No newline at end of file + +SET arguments=-UpdatesAtLogon -UpdatesInterval Weekly -StartMenuShortcut + +powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file """%~dp0Winget-AutoUpdate-Install.ps1"" %arguments%'" -Verb RunAs \ No newline at end of file From 9fed7d88798f647ec315078b66bf3e3e32af0cb9 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Oct 2022 22:12:09 +0200 Subject: [PATCH 2/3] notification first ? better user experience i guess --- Winget-AutoUpdate/user-run.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/user-run.ps1 b/Winget-AutoUpdate/user-run.ps1 index 11a421f..9ca3a18 100644 --- a/Winget-AutoUpdate/user-run.ps1 +++ b/Winget-AutoUpdate/user-run.ps1 @@ -57,12 +57,12 @@ elseif ($Help) { } else { try { - #Run scheduled task - Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction Stop | Start-ScheduledTask -ErrorAction Stop #Starting check - Send notification $Message = $NotifLocale.local.outputs.output[6].message $MessageType = "info" Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction + #Run scheduled task + Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction Stop | Start-ScheduledTask -ErrorAction Stop } catch { #Check failed - Just send notification From abe58250055676fddc3900e8bc492c04f44a36ee Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Oct 2022 22:15:13 +0200 Subject: [PATCH 3/3] Update install.bat --- install.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.bat b/install.bat index 3fd1e86..1c0b08e 100644 --- a/install.bat +++ b/install.bat @@ -2,4 +2,4 @@ SET arguments=-UpdatesAtLogon -UpdatesInterval Weekly -StartMenuShortcut -powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file """%~dp0Winget-AutoUpdate-Install.ps1"" %arguments%'" -Verb RunAs \ No newline at end of file +powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file """%~dp0Winget-AutoUpdate-Install.ps1"" %arguments%'" -Verb RunAs