diff --git a/README.md b/README.md index 24ee153..d749e86 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,12 @@ Bypass Black/White list when run in user context **-NoClean** Keep critical files when installing/uninstalling. This setting will keep "excluded_apps.txt", "included_apps.txt", "mods" and "logs" as they were. +**-DesktopShortcut** +Create a shortcut for user interaction on the Desktop to run task `Winget-AutoUpdate` + +**-StartMenuShortcut** +Create shortcuts for user interaction in the Start Menu to run task `Winget-AutoUpdate`, open Logs and Web Help + **-NotificationLevel** Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup). diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index eb175e3..aaf5c40 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -31,6 +31,12 @@ Remove scheduled tasks and scripts. .PARAMETER NoClean Keep critical files when installing/uninstalling +.PARAMETER DesktopShortcut +Create a shortcut for user interaction on the Desktop to run task "Winget-AutoUpdate" + +.PARAMETER StartMenuShortcut +Create shortcuts for user interaction in the Start Menu to run task "Winget-AutoUpdate", open Logs and Web Help + .PARAMETER NotificationLevel Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup). @@ -56,7 +62,7 @@ Configure WAU to bypass the Black/White list when run in user context .\winget-install-and-update.ps1 -Silent -UseWhiteList .EXAMPLE -.\winget-install-and-update.ps1 -Silent -ListPath https://www.domain.com/WAULists +.\winget-install-and-update.ps1 -Silent -ListPath https://www.domain.com/WAULists -StartMenuShortcut .EXAMPLE .\winget-install-and-update.ps1 -Silent -UpdatesAtLogon -UpdatesInterval Weekly @@ -76,6 +82,8 @@ param( [Parameter(Mandatory = $False)] [Switch] $RunOnMetered = $false, [Parameter(Mandatory = $False)] [Switch] $Uninstall = $false, [Parameter(Mandatory = $False)] [Switch] $NoClean = $false, + [Parameter(Mandatory = $False)] [Switch] $DesktopShortcut = $false, + [Parameter(Mandatory = $False)] [Switch] $StartMenuShortcut = $false, [Parameter(Mandatory = $False)] [Switch] $UseWhiteList = $false, [Parameter(Mandatory = $False)] [ValidateSet("Full", "SuccessOnly", "None")] [String] $NotificationLevel = "Full", [Parameter(Mandatory = $False)] [Switch] $UpdatesAtLogon = $false, @@ -323,12 +331,26 @@ function Install-WingetAutoUpdate { New-ItemProperty $regPath -Name WAU_DoNotRunOnMetered -Value 1 -PropertyType DWord -Force | Out-Null } if ($ListPath){ - New-ItemProperty $regPath -Name ListPath -Value $ListPath -Force | Out-Null + New-ItemProperty $regPath -Name WAU_ListPath -Value $ListPath -Force | Out-Null } if ($BypassListForUsers){ New-ItemProperty $regPath -Name WAU_BypassListForUsers -Value 1 -PropertyType DWord -Force | Out-Null } + #Create Shortcuts + if ($StartMenuShortcut) { + if (!(Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) { + New-Item -ItemType Directory -Force -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" | Out-Null + } + Add-Shortcut "wscript.exe" "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)\WAU - Check for updated Apps.lnk" "`"$($WingetUpdatePath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WingetUpdatePath)\user-run.ps1`"`"" "${env:SystemRoot}\System32\shell32.dll,-16739" "Manual start of Winget-AutoUpdate (WAU)..." + Add-Shortcut "wscript.exe" "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)\WAU - Open logs.lnk" "`"$($WingetUpdatePath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WingetUpdatePath)\user-run.ps1`" -Logs`"" "${env:SystemRoot}\System32\shell32.dll,-16763" "Open existing WAU logs..." + Add-Shortcut "wscript.exe" "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)\WAU - Web Help.lnk" "`"$($WingetUpdatePath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WingetUpdatePath)\user-run.ps1`" -Help`"" "${env:SystemRoot}\System32\shell32.dll,-24" "Help for WAU..." + } + + if ($DesktopShortcut) { + Add-Shortcut "wscript.exe" "${env:Public}\Desktop\WAU - Check for updated Apps.lnk" "`"$($WingetUpdatePath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WingetUpdatePath)\user-run.ps1`"`"" "${env:SystemRoot}\System32\shell32.dll,-16739" "Manual start of Winget-AutoUpdate (WAU)..." + } + Write-host "WAU Installation succeeded!" -ForegroundColor Green Start-sleep 1 @@ -366,6 +388,14 @@ function Uninstall-WingetAutoUpdate { & reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null & reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null + if ((Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) { + Remove-Item -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" -Recurse -Force | Out-Null + } + + if ((Test-Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk")) { + Remove-Item -Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk" -Force | Out-Null + } + Write-host "Uninstallation succeeded!" -ForegroundColor Green Start-sleep 1 } @@ -417,6 +447,15 @@ function Start-WingetAutoUpdate { } } +function Add-Shortcut ($Target, $Shortcut, $Arguments, $Icon, $Description) { + $WScriptShell = New-Object -ComObject WScript.Shell + $Shortcut = $WScriptShell.CreateShortcut($Shortcut) + $Shortcut.TargetPath = $Target + $Shortcut.Arguments = $Arguments + $Shortcut.IconLocation = $Icon + $Shortcut.Description = $Description + $Shortcut.Save() +} <# MAIN #> diff --git a/Winget-AutoUpdate/WAU-Uninstall.ps1 b/Winget-AutoUpdate/WAU-Uninstall.ps1 index 8189dff..f0c95e1 100644 --- a/Winget-AutoUpdate/WAU-Uninstall.ps1 +++ b/Winget-AutoUpdate/WAU-Uninstall.ps1 @@ -56,6 +56,14 @@ try { & reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null } + if ((Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) { + Remove-Item -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" -Recurse -Force | Out-Null + } + + if ((Test-Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk")) { + Remove-Item -Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk" -Force | Out-Null + } + Write-host "Uninstallation succeeded!" -ForegroundColor Green } else { diff --git a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 index b505e0d..f635e6b 100644 --- a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 +++ b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 @@ -2,7 +2,7 @@ function Start-NotifTask ($Title, $Message, $MessageType, $Balise, $OnClickAction) { - if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success")) { + if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success") -or ($UserRun)) { #Prepare OnClickAction (if set) if ($OnClickAction){ diff --git a/Winget-AutoUpdate/locale/de.xml b/Winget-AutoUpdate/locale/de.xml index b373116..81375d0 100644 --- a/Winget-AutoUpdate/locale/de.xml +++ b/Winget-AutoUpdate/locale/de.xml @@ -30,5 +30,17 @@ Bitte wenden sie sich an den Support. + + + Logs are not available yet! + + + + Starting a manual check for updated apps... + + + + Couldn't start a manual check for updated apps! + diff --git a/Winget-AutoUpdate/locale/en.xml b/Winget-AutoUpdate/locale/en.xml index d9c7554..6a2799c 100644 --- a/Winget-AutoUpdate/locale/en.xml +++ b/Winget-AutoUpdate/locale/en.xml @@ -30,5 +30,17 @@ Please contact support. + + + Logs are not available yet! + + + + Starting a manual check for updated apps... + + + + Couldn't start a manual check for updated apps! + diff --git a/Winget-AutoUpdate/locale/es.xml b/Winget-AutoUpdate/locale/es.xml index aef9e3f..3a083c1 100644 --- a/Winget-AutoUpdate/locale/es.xml +++ b/Winget-AutoUpdate/locale/es.xml @@ -30,5 +30,17 @@ Por favor, póngase en contacto con el servicio de soporte. + + + Logs are not available yet! + + + + Starting a manual check for updated apps... + + + + Couldn't start a manual check for updated apps! + diff --git a/Winget-AutoUpdate/locale/fi.xml b/Winget-AutoUpdate/locale/fi.xml index 570b5c4..9a576a2 100644 --- a/Winget-AutoUpdate/locale/fi.xml +++ b/Winget-AutoUpdate/locale/fi.xml @@ -30,5 +30,17 @@ Ole yhteydessä tukeen. + + + Logs are not available yet! + + + + Starting a manual check for updated apps... + + + + Couldn't start a manual check for updated apps! + diff --git a/Winget-AutoUpdate/locale/fr.xml b/Winget-AutoUpdate/locale/fr.xml index 3362d5a..ad76473 100644 --- a/Winget-AutoUpdate/locale/fr.xml +++ b/Winget-AutoUpdate/locale/fr.xml @@ -30,5 +30,17 @@ Contacter le support. + + + Logs are not available yet! + + + + Starting a manual check for updated apps... + + + + Couldn't start a manual check for updated apps! + diff --git a/Winget-AutoUpdate/locale/hu.xml b/Winget-AutoUpdate/locale/hu.xml index 9cc70f1..8ac1671 100644 --- a/Winget-AutoUpdate/locale/hu.xml +++ b/Winget-AutoUpdate/locale/hu.xml @@ -30,5 +30,17 @@ Kérjük, forduljon az ügyfélszolgálathoz. + + + Logs are not available yet! + + + + Starting a manual check for updated apps... + + + + Couldn't start a manual check for updated apps! + diff --git a/Winget-AutoUpdate/locale/it.xml b/Winget-AutoUpdate/locale/it.xml index df3b99a..6e67787 100644 --- a/Winget-AutoUpdate/locale/it.xml +++ b/Winget-AutoUpdate/locale/it.xml @@ -30,5 +30,17 @@ Per favore contatta il supporto. + + + Logs are not available yet! + + + + Starting a manual check for updated apps... + + + + Couldn't start a manual check for updated apps! + diff --git a/Winget-AutoUpdate/locale/nl.xml b/Winget-AutoUpdate/locale/nl.xml index 16451dc..53bd252 100644 --- a/Winget-AutoUpdate/locale/nl.xml +++ b/Winget-AutoUpdate/locale/nl.xml @@ -30,5 +30,17 @@ Neem contact op met support. + + + Logs are not available yet! + + + + Starting a manual check for updated apps... + + + + Couldn't start a manual check for updated apps! + diff --git a/Winget-AutoUpdate/locale/pl.xml b/Winget-AutoUpdate/locale/pl.xml index a59e7a9..1b86530 100644 --- a/Winget-AutoUpdate/locale/pl.xml +++ b/Winget-AutoUpdate/locale/pl.xml @@ -30,5 +30,17 @@ Skontaktuj się z pomocą techniczną. + + + Logs are not available yet! + + + + Starting a manual check for updated apps... + + + + Couldn't start a manual check for updated apps! + diff --git a/Winget-AutoUpdate/locale/sv.xml b/Winget-AutoUpdate/locale/sv.xml index 7371bb3..3a2ab29 100644 --- a/Winget-AutoUpdate/locale/sv.xml +++ b/Winget-AutoUpdate/locale/sv.xml @@ -30,5 +30,17 @@ Vänligen kontakta supporten. + + + Loggarna är inte tillgängliga ännu! + + + + Startar en manuell koll efter uppdaterade appar... + + + + Kunde inte starta en manuell koll efter uppdaterade appar! + diff --git a/Winget-AutoUpdate/user-run.ps1 b/Winget-AutoUpdate/user-run.ps1 new file mode 100644 index 0000000..11a421f --- /dev/null +++ b/Winget-AutoUpdate/user-run.ps1 @@ -0,0 +1,73 @@ +<# +.SYNOPSIS +Handle user interaction from shortcuts and show a Toast + +.DESCRIPTION +Act on shortcut run (DEFAULT: Check for updated Apps) + +.PARAMETER Logs +Open the Log file from Winget-AutoUpdate installation location + +.PARAMETER Help +Open the Web Help page +https://github.com/Romanitho/Winget-AutoUpdate + +.EXAMPLE +.\user-run.ps1 -Logs + +#> + +[CmdletBinding()] +param( + [Parameter(Mandatory=$False)] [Switch] $Logs = $false, + [Parameter(Mandatory=$False)] [Switch] $Help = $false +) + +<# MAIN #> + +#Get Working Dir +$Script:WorkingDir = $PSScriptRoot + +#Load functions +. $WorkingDir\functions\Get-NotifLocale.ps1 +. $WorkingDir\functions\Start-NotifTask.ps1 + +#Set common variables +$OnClickAction = "$WorkingDir\logs\updates.log" +$Title = "Winget-AutoUpdate (WAU)" +$Balise = "Winget-AutoUpdate (WAU)" +$UserRun = $True + +#Get Toast Locale function +Get-NotifLocale + +if ($Logs) { + if ((Test-Path "$WorkingDir\logs\updates.log")) { + Invoke-Item "$WorkingDir\logs\updates.log" + } + else { + #Not available yet + $Message = $NotifLocale.local.outputs.output[5].message + $MessageType = "warning" + Start-NotifTask $Title $Message $MessageType $Balise + } +} +elseif ($Help) { + Start-Process "https://github.com/Romanitho/Winget-AutoUpdate" +} +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 + } + catch { + #Check failed - Just send notification + $Message = $NotifLocale.local.outputs.output[7].message + $MessageType = "error" + Start-NotifTask $Title $Message $MessageType $Balise + } +} diff --git a/Winget-AutoUpdate/winget-upgrade.ps1 b/Winget-AutoUpdate/winget-upgrade.ps1 index 624e2aa..beb8f6c 100644 --- a/Winget-AutoUpdate/winget-upgrade.ps1 +++ b/Winget-AutoUpdate/winget-upgrade.ps1 @@ -76,17 +76,23 @@ if (Test-Network) { } #Get External ListPath - if ($WAUConfig.ListPath) { - Write-Log "WAU uses External Lists from $WAUConfig.ListPath" - $NewList = Test-ListPath $WAUConfig.ListPath $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation + if ($WAUConfig.WAU_ListPath) { + Write-Log "WAU uses External Lists from: $($WAUConfig.WAU_ListPath)" + $NewList = Test-ListPath $WAUConfig.WAU_ListPath $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation if ($NewList) { - Write-Log "Newer List downloaded to local path" + Write-Log "Newer List copied/downloaded to local path: $($WAUConfig.InstallLocation)" "Yellow" } else { - Write-Log "No newer List detected" + if ((Test-Path "$WorkingDir\included_apps.txt") -or (Test-Path "$WorkingDir\excluded_apps.txt")) { + Write-Log "List is up to date." "Green" + } + else { + Write-Log "List doesn't exist!" "Red" + Exit 0 + } } } - + #Get White or Black list if ($WAUConfig.WAU_UseWhiteList -eq 1) { Write-Log "WAU uses White List config"