Merge pull request #178 from KnifMelti/KnifDev-UserShortcuts-New
Knif dev user shortcuts newpull/179/head
commit
3ae0cff2c0
|
@ -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).
|
||||
|
||||
|
|
|
@ -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 #>
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -30,5 +30,17 @@
|
|||
<!--Please contact support-->
|
||||
<message>Bitte wenden sie sich an den Support.</message>
|
||||
</output>
|
||||
<output id="5">
|
||||
<!--Logs are not available yet-->
|
||||
<message>Logs are not available yet!</message>
|
||||
</output>
|
||||
<output id="6">
|
||||
<!--Starting a manual check for updated apps-->
|
||||
<message>Starting a manual check for updated apps...</message>
|
||||
</output>
|
||||
<output id="7">
|
||||
<!--Couldn't start a manual check for updated apps-->
|
||||
<message>Couldn't start a manual check for updated apps!</message>
|
||||
</output>
|
||||
</outputs>
|
||||
</local>
|
||||
|
|
|
@ -30,5 +30,17 @@
|
|||
<!--Please contact support-->
|
||||
<message>Please contact support.</message>
|
||||
</output>
|
||||
<output id="5">
|
||||
<!--Logs are not available yet-->
|
||||
<message>Logs are not available yet!</message>
|
||||
</output>
|
||||
<output id="6">
|
||||
<!--Starting a manual check for updated apps-->
|
||||
<message>Starting a manual check for updated apps...</message>
|
||||
</output>
|
||||
<output id="7">
|
||||
<!--Couldn't start a manual check for updated apps-->
|
||||
<message>Couldn't start a manual check for updated apps!</message>
|
||||
</output>
|
||||
</outputs>
|
||||
</local>
|
||||
|
|
|
@ -30,5 +30,17 @@
|
|||
<!--Please contact support-->
|
||||
<message>Por favor, póngase en contacto con el servicio de soporte.</message>
|
||||
</output>
|
||||
<output id="5">
|
||||
<!--Logs are not available yet-->
|
||||
<message>Logs are not available yet!</message>
|
||||
</output>
|
||||
<output id="6">
|
||||
<!--Starting a manual check for updated apps-->
|
||||
<message>Starting a manual check for updated apps...</message>
|
||||
</output>
|
||||
<output id="7">
|
||||
<!--Couldn't start a manual check for updated apps-->
|
||||
<message>Couldn't start a manual check for updated apps!</message>
|
||||
</output>
|
||||
</outputs>
|
||||
</local>
|
||||
|
|
|
@ -30,5 +30,17 @@
|
|||
<!--Please contact support-->
|
||||
<message>Ole yhteydessä tukeen.</message>
|
||||
</output>
|
||||
<output id="5">
|
||||
<!--Logs are not available yet-->
|
||||
<message>Logs are not available yet!</message>
|
||||
</output>
|
||||
<output id="6">
|
||||
<!--Starting a manual check for updated apps-->
|
||||
<message>Starting a manual check for updated apps...</message>
|
||||
</output>
|
||||
<output id="7">
|
||||
<!--Couldn't start a manual check for updated apps-->
|
||||
<message>Couldn't start a manual check for updated apps!</message>
|
||||
</output>
|
||||
</outputs>
|
||||
</local>
|
||||
|
|
|
@ -30,5 +30,17 @@
|
|||
<!--Please contact support-->
|
||||
<message>Contacter le support.</message>
|
||||
</output>
|
||||
<output id="5">
|
||||
<!--Logs are not available yet-->
|
||||
<message>Logs are not available yet!</message>
|
||||
</output>
|
||||
<output id="6">
|
||||
<!--Starting a manual check for updated apps-->
|
||||
<message>Starting a manual check for updated apps...</message>
|
||||
</output>
|
||||
<output id="7">
|
||||
<!--Couldn't start a manual check for updated apps-->
|
||||
<message>Couldn't start a manual check for updated apps!</message>
|
||||
</output>
|
||||
</outputs>
|
||||
</local>
|
||||
|
|
|
@ -30,5 +30,17 @@
|
|||
<!--Please contact support-->
|
||||
<message>Kérjük, forduljon az ügyfélszolgálathoz.</message>
|
||||
</output>
|
||||
<output id="5">
|
||||
<!--Logs are not available yet-->
|
||||
<message>Logs are not available yet!</message>
|
||||
</output>
|
||||
<output id="6">
|
||||
<!--Starting a manual check for updated apps-->
|
||||
<message>Starting a manual check for updated apps...</message>
|
||||
</output>
|
||||
<output id="7">
|
||||
<!--Couldn't start a manual check for updated apps-->
|
||||
<message>Couldn't start a manual check for updated apps!</message>
|
||||
</output>
|
||||
</outputs>
|
||||
</local>
|
||||
|
|
|
@ -30,5 +30,17 @@
|
|||
<!--Please contact support-->
|
||||
<message>Per favore contatta il supporto.</message>
|
||||
</output>
|
||||
<output id="5">
|
||||
<!--Logs are not available yet-->
|
||||
<message>Logs are not available yet!</message>
|
||||
</output>
|
||||
<output id="6">
|
||||
<!--Starting a manual check for updated apps-->
|
||||
<message>Starting a manual check for updated apps...</message>
|
||||
</output>
|
||||
<output id="7">
|
||||
<!--Couldn't start a manual check for updated apps-->
|
||||
<message>Couldn't start a manual check for updated apps!</message>
|
||||
</output>
|
||||
</outputs>
|
||||
</local>
|
||||
|
|
|
@ -30,5 +30,17 @@
|
|||
<!--Please contact support-->
|
||||
<message>Neem contact op met support.</message>
|
||||
</output>
|
||||
<output id="5">
|
||||
<!--Logs are not available yet-->
|
||||
<message>Logs are not available yet!</message>
|
||||
</output>
|
||||
<output id="6">
|
||||
<!--Starting a manual check for updated apps-->
|
||||
<message>Starting a manual check for updated apps...</message>
|
||||
</output>
|
||||
<output id="7">
|
||||
<!--Couldn't start a manual check for updated apps-->
|
||||
<message>Couldn't start a manual check for updated apps!</message>
|
||||
</output>
|
||||
</outputs>
|
||||
</local>
|
||||
|
|
|
@ -30,5 +30,17 @@
|
|||
<!--Please contact support-->
|
||||
<message>Skontaktuj się z pomocą techniczną.</message>
|
||||
</output>
|
||||
<output id="5">
|
||||
<!--Logs are not available yet-->
|
||||
<message>Logs are not available yet!</message>
|
||||
</output>
|
||||
<output id="6">
|
||||
<!--Starting a manual check for updated apps-->
|
||||
<message>Starting a manual check for updated apps...</message>
|
||||
</output>
|
||||
<output id="7">
|
||||
<!--Couldn't start a manual check for updated apps-->
|
||||
<message>Couldn't start a manual check for updated apps!</message>
|
||||
</output>
|
||||
</outputs>
|
||||
</local>
|
||||
|
|
|
@ -30,5 +30,17 @@
|
|||
<!--Please contact support-->
|
||||
<message>Vänligen kontakta supporten.</message>
|
||||
</output>
|
||||
<output id="5">
|
||||
<!--Logs are not available yet-->
|
||||
<message>Loggarna är inte tillgängliga ännu!</message>
|
||||
</output>
|
||||
<output id="6">
|
||||
<!--Starting a manual check for updated apps-->
|
||||
<message>Startar en manuell koll efter uppdaterade appar...</message>
|
||||
</output>
|
||||
<output id="7">
|
||||
<!--Couldn't start a manual check for updated apps-->
|
||||
<message>Kunde inte starta en manuell koll efter uppdaterade appar!</message>
|
||||
</output>
|
||||
</outputs>
|
||||
</local>
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue