From b1c468117a7769fec74d7462772c88cc98eec6bd Mon Sep 17 00:00:00 2001 From: Romanitho <96626929+Romanitho@users.noreply.github.com> Date: Tue, 18 Jan 2022 14:12:18 +0100 Subject: [PATCH] Install location variable Editable install source --- winget-install-and-update.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/winget-install-and-update.ps1 b/winget-install-and-update.ps1 index 381ea1e..80d2368 100644 --- a/winget-install-and-update.ps1 +++ b/winget-install-and-update.ps1 @@ -1,5 +1,7 @@ -#Create winget-update folder and content +#Create winget-update folder and content structure $WingetUpdatePath = "$env:ProgramData\winget-update" + +#Copy files to location if (!(Test-Path $WingetUpdatePath)){ New-Item -ItemType Directory -Force -Path $WingetUpdatePath } @@ -11,7 +13,7 @@ Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WingetUpdatePath & reg add "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /v IconUri /t REG_EXPAND_SZ /d %SystemRoot%\system32\@WindowsUpdateToastIcon.png /f # Settings for the scheduled task for Updates -$taskAction = New-ScheduledTaskAction –Execute "powershell.exe" -Argument '-ExecutionPolicy Bypass -File "C:\ProgramData\winget-update\winget-upgrade.ps1"' +$taskAction = New-ScheduledTaskAction –Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -File `"$($WingetUpdatePath)\winget-upgrade.ps1`"" $taskTrigger1 = New-ScheduledTaskTrigger -AtLogOn $taskTrigger2 = New-ScheduledTaskTrigger -Daily -At 6AM $taskUserPrincipal = New-ScheduledTaskPrincipal -UserId 'SYSTEM' -RunLevel Highest @@ -22,7 +24,7 @@ $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Set Register-ScheduledTask -TaskName 'Winget Update' -InputObject $task -Force # Settings for the scheduled task for Notifications -$taskAction = New-ScheduledTaskAction –Execute "wscript.exe" -Argument '"C:\ProgramData\winget-update\Invisible.vbs" "powershell.exe -ExecutionPolicy Bypass -File C:\ProgramData\winget-update\winget-notify.ps1"' +$taskAction = New-ScheduledTaskAction –Execute "wscript.exe" -Argument "`"$($WingetUpdatePath)\Invisible.vbs`" `"powershell.exe -ExecutionPolicy Bypass -File `"`"`"$($WingetUpdatePath)\winget-notify.ps1`"`"" $taskUserPrincipal = New-ScheduledTaskPrincipal -GroupId S-1-5-32-545 $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 00:05:00