Merge pull request #2 from Romanitho/dev

Renaming few things to match Winget-AutoUpdate
pull/3/head v1.3.2
Romain 2022-02-14 17:43:39 +01:00 committed by GitHub
commit 215e79d6c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 373 additions and 365 deletions

View File

@ -11,7 +11,7 @@ https://github.com/Romanitho/Winget-AutoUpdate
Install Winget-AutoUpdate and prerequisites silently Install Winget-AutoUpdate and prerequisites silently
.PARAMETER WingetUpdatePath .PARAMETER WingetUpdatePath
Specify Winget-AutoUpdate installation localtion. Default: C:\ProgramData\winget-update\ Specify Winget-AutoUpdate installation localtion. Default: C:\ProgramData\Winget-AutoUpdate\
.PARAMETER DoNotUpdate .PARAMETER DoNotUpdate
Do not run Winget-autoupdate after installation. By default, Winget-AutoUpdate is run just after installation. Do not run Winget-autoupdate after installation. By default, Winget-AutoUpdate is run just after installation.
@ -23,7 +23,7 @@ Do not run Winget-autoupdate after installation. By default, Winget-AutoUpdate i
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$False)] [Alias('S')] [Switch] $Silent = $false, [Parameter(Mandatory=$False)] [Alias('S')] [Switch] $Silent = $false,
[Parameter(Mandatory=$False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\winget-update", [Parameter(Mandatory=$False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate",
[Parameter(Mandatory=$False)] [Switch] $DoNotUpdate = $false [Parameter(Mandatory=$False)] [Switch] $DoNotUpdate = $false
) )
@ -78,11 +78,19 @@ function Check-Prerequisites{
function Install-WingetAutoUpdate{ function Install-WingetAutoUpdate{
try{ try{
#Check if previous version location exists and delete
$OldWingetUpdatePath = $WingetUpdatePath.Replace("\Winget-AutoUpdate","\winget-update")
if (Test-Path ($OldWingetUpdatePath)){
Remove-Item $OldWingetUpdatePath -Force -Recurse
}
Get-ScheduledTask -TaskName "Winget Update" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
Get-ScheduledTask -TaskName "Winget Update Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
#Copy files to location #Copy files to location
if (!(Test-Path $WingetUpdatePath)){ if (!(Test-Path $WingetUpdatePath)){
New-Item -ItemType Directory -Force -Path $WingetUpdatePath New-Item -ItemType Directory -Force -Path $WingetUpdatePath
} }
Copy-Item -Path "$PSScriptRoot\winget-update\*" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue
Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue
# Set dummy regkeys for notification name and icon # Set dummy regkeys for notification name and icon
@ -98,7 +106,7 @@ function Install-WingetAutoUpdate{
# Set up the task, and register it # Set up the task, and register it
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings -Trigger $taskTrigger2,$taskTrigger1 $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings -Trigger $taskTrigger2,$taskTrigger1
Register-ScheduledTask -TaskName 'Winget Update' -InputObject $task -Force Register-ScheduledTask -TaskName 'Winget-AutoUpdate' -InputObject $task -Force
# Settings for the scheduled task for Notifications # Settings for the scheduled task for Notifications
$taskAction = New-ScheduledTaskAction Execute "wscript.exe" -Argument "`"$($WingetUpdatePath)\Invisible.vbs`" `"powershell.exe -ExecutionPolicy Bypass -File `"`"`"$($WingetUpdatePath)\winget-notify.ps1`"`"" $taskAction = New-ScheduledTaskAction Execute "wscript.exe" -Argument "`"$($WingetUpdatePath)\Invisible.vbs`" `"powershell.exe -ExecutionPolicy Bypass -File `"`"`"$($WingetUpdatePath)\winget-notify.ps1`"`""
@ -107,7 +115,7 @@ function Install-WingetAutoUpdate{
# Set up the task, and register it # Set up the task, and register it
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
Register-ScheduledTask -TaskName 'Winget Update Notify' -InputObject $task -Force Register-ScheduledTask -TaskName 'Winget-AutoUpdate-Notify' -InputObject $task -Force
Write-host "`nInstallation succeeded!" -ForegroundColor Green Write-host "`nInstallation succeeded!" -ForegroundColor Green
Start-sleep 1 Start-sleep 1
@ -138,7 +146,7 @@ function Start-WingetAutoUpdate{
if ($RunWinget -eq "y"){ if ($RunWinget -eq "y"){
try{ try{
Write-host "Running Winget-AutoUpdate..." -ForegroundColor Yellow Write-host "Running Winget-AutoUpdate..." -ForegroundColor Yellow
Get-ScheduledTask -TaskName "Winget Update" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue
} }
catch{ catch{
Write-host "Failed to run Winget-AutoUpdate..." -ForegroundColor Red Write-host "Failed to run Winget-AutoUpdate..." -ForegroundColor Red

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -1,7 +1,7 @@
#Send Notif Script #Send Notif Script
#get xml notif config #get xml notif config
[xml]$NotifConf = Get-Content "$env:ProgramData\winget-update\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue [xml]$NotifConf = Get-Content "$env:ProgramData\Winget-AutoUpdate\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
if (!($NotifConf)) {break} if (!($NotifConf)) {break}
#Load Assemblies #Load Assemblies

View File

@ -62,7 +62,7 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
"@ "@
#Save XML File #Save XML File
$ToastTemplateLocation = "$env:ProgramData\winget-update\" $ToastTemplateLocation = "$env:ProgramData\Winget-AutoUpdate\"
if (!(Test-Path $ToastTemplateLocation)){ if (!(Test-Path $ToastTemplateLocation)){
New-Item -ItemType Directory -Force -Path $ToastTemplateLocation New-Item -ItemType Directory -Force -Path $ToastTemplateLocation
} }

View File

@ -1,2 +1,2 @@
@echo off @echo off
powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-executionpolicy bypass -file """%~dp0winget-install-and-update.ps1"" -Silent'" -Verb RunAs powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-executionpolicy bypass -file """%~dp0Winget-AutoUpdate-Install.ps1"" -Silent'" -Verb RunAs