2022-10-18 13:23:39 +00:00
|
|
|
<#
|
2022-02-12 15:35:51 +00:00
|
|
|
.SYNOPSIS
|
|
|
|
Configure Winget to daily update installed apps.
|
|
|
|
|
|
|
|
.DESCRIPTION
|
|
|
|
Install powershell scripts and scheduled task to daily run Winget upgrade and notify connected users.
|
2023-03-31 15:56:07 +00:00
|
|
|
Posibility to exclude apps from auto-update
|
2022-02-12 15:35:51 +00:00
|
|
|
https://github.com/Romanitho/Winget-AutoUpdate
|
|
|
|
|
|
|
|
.PARAMETER Silent
|
|
|
|
Install Winget-AutoUpdate and prerequisites silently
|
|
|
|
|
2023-01-13 02:33:00 +00:00
|
|
|
.PARAMETER MaxLogFiles
|
|
|
|
Specify number of allowed log files (Default is 3 of 0-99: Setting MaxLogFiles to 0 don't delete any old archived log files, 1 keeps the original one and just let it grow)
|
|
|
|
|
|
|
|
.PARAMETER MaxLogSize
|
|
|
|
Specify the size of the log file in bytes before rotating. (Default is 1048576 = 1 MB)
|
|
|
|
|
2022-02-12 15:35:51 +00:00
|
|
|
.PARAMETER WingetUpdatePath
|
2022-02-14 16:28:22 +00:00
|
|
|
Specify Winget-AutoUpdate installation localtion. Default: C:\ProgramData\Winget-AutoUpdate\
|
2022-02-12 15:35:51 +00:00
|
|
|
|
|
|
|
.PARAMETER DoNotUpdate
|
2022-03-07 01:35:40 +00:00
|
|
|
Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate is run just after installation.
|
|
|
|
|
|
|
|
.PARAMETER DisableWAUAutoUpdate
|
|
|
|
Disable Winget-AutoUpdate update checking. By default, WAU auto update if new version is available on Github.
|
2022-02-12 15:35:51 +00:00
|
|
|
|
2022-04-05 10:38:54 +00:00
|
|
|
.PARAMETER UseWhiteList
|
|
|
|
Use White List instead of Black List. This setting will not create the "exclude_apps.txt" but "include_apps.txt"
|
|
|
|
|
2022-09-20 01:22:29 +00:00
|
|
|
.PARAMETER ListPath
|
2023-03-07 15:17:40 +00:00
|
|
|
Get Black/White List from Path (URL/UNC/GPO/Local)
|
2022-09-20 01:22:29 +00:00
|
|
|
|
2022-11-02 17:47:21 +00:00
|
|
|
.PARAMETER ModsPath
|
2023-03-07 15:17:40 +00:00
|
|
|
Get mods from Path (URL/UNC/Local/AzureBlob)
|
|
|
|
|
|
|
|
.PARAMETER AzureBlobURL
|
|
|
|
Set the Azure Storage Blob URL including the SAS token. The token requires at a minimum 'Read' and 'List' permissions. It is recommended to set this at the container level
|
2022-11-02 17:47:21 +00:00
|
|
|
|
2022-04-02 17:24:18 +00:00
|
|
|
.PARAMETER Uninstall
|
|
|
|
Remove scheduled tasks and scripts.
|
|
|
|
|
2022-07-30 07:31:05 +00:00
|
|
|
.PARAMETER NoClean
|
2022-07-30 07:41:03 +00:00
|
|
|
Keep critical files when installing/uninstalling
|
2022-07-30 07:31:05 +00:00
|
|
|
|
2022-10-11 14:03:57 +00:00
|
|
|
.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
|
|
|
|
|
2022-04-24 08:51:51 +00:00
|
|
|
.PARAMETER NotificationLevel
|
|
|
|
Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup).
|
|
|
|
|
2022-04-30 10:00:39 +00:00
|
|
|
.PARAMETER UpdatesAtLogon
|
|
|
|
Set WAU to run at user logon.
|
|
|
|
|
|
|
|
.PARAMETER UpdatesInterval
|
2022-11-24 20:05:40 +00:00
|
|
|
Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never
|
2022-10-05 14:43:04 +00:00
|
|
|
|
|
|
|
.PARAMETER UpdatesAtTime
|
|
|
|
Specify the time of the update interval execution time. Default 6AM
|
2022-04-30 10:00:39 +00:00
|
|
|
|
2022-06-29 15:32:03 +00:00
|
|
|
.PARAMETER RunOnMetered
|
|
|
|
Run WAU on metered connection. Default No.
|
|
|
|
|
2022-10-24 23:43:50 +00:00
|
|
|
.PARAMETER InstallUserContext
|
|
|
|
Install WAU with system and user context executions
|
|
|
|
|
2022-10-10 14:05:36 +00:00
|
|
|
.PARAMETER BypassListForUsers
|
2023-05-04 08:42:42 +00:00
|
|
|
Configure WAU to bypass the Black/White list when run in user context. Applications installed in system context will be ignored under user context.
|
2022-10-10 14:05:36 +00:00
|
|
|
|
2022-02-12 15:35:51 +00:00
|
|
|
.EXAMPLE
|
2023-01-13 02:33:00 +00:00
|
|
|
.\Winget-AutoUpdate-Install.ps1 -Silent -DoNotUpdate -MaxLogFiles 4 -MaxLogSize 2097152
|
2022-04-05 13:23:36 +00:00
|
|
|
|
|
|
|
.EXAMPLE
|
2022-10-13 23:09:06 +00:00
|
|
|
.\Winget-AutoUpdate-Install.ps1 -Silent -UseWhiteList
|
2022-04-05 13:23:36 +00:00
|
|
|
|
2022-09-20 01:22:29 +00:00
|
|
|
.EXAMPLE
|
2022-11-24 20:05:40 +00:00
|
|
|
.\Winget-AutoUpdate-Install.ps1 -Silent -ListPath https://www.domain.com/WAULists -StartMenuShortcut -UpdatesInterval BiDaily
|
2022-09-20 01:22:29 +00:00
|
|
|
|
2022-11-02 17:47:21 +00:00
|
|
|
.EXAMPLE
|
2022-11-24 20:05:40 +00:00
|
|
|
.\Winget-AutoUpdate-Install.ps1 -Silent -ModsPath https://www.domain.com/WAUMods -DesktopShortcut -UpdatesInterval Weekly
|
2022-11-02 17:47:21 +00:00
|
|
|
|
2022-04-30 10:00:39 +00:00
|
|
|
.EXAMPLE
|
2022-10-13 23:09:06 +00:00
|
|
|
.\Winget-AutoUpdate-Install.ps1 -Silent -UpdatesAtLogon -UpdatesInterval Weekly
|
2022-04-30 10:00:39 +00:00
|
|
|
|
2022-07-30 07:31:05 +00:00
|
|
|
.EXAMPLE
|
2022-07-30 07:34:10 +00:00
|
|
|
.\Winget-AutoUpdate-Install.ps1 -Silent -Uninstall -NoClean
|
2022-07-30 07:31:05 +00:00
|
|
|
|
2022-02-12 15:35:51 +00:00
|
|
|
#>
|
|
|
|
|
|
|
|
[CmdletBinding()]
|
|
|
|
param(
|
2022-06-10 08:26:41 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Alias('S')] [Switch] $Silent = $false,
|
|
|
|
[Parameter(Mandatory = $False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate",
|
2022-09-23 16:00:46 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Alias('List')] [String] $ListPath,
|
2022-11-02 17:47:21 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Alias('Mods')] [String] $ModsPath,
|
2023-03-07 15:17:40 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Alias('AzureBlobURL')] [String] $AzureBlobSASURL,
|
2022-06-10 08:26:41 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Switch] $DoNotUpdate = $false,
|
|
|
|
[Parameter(Mandatory = $False)] [Switch] $DisableWAUAutoUpdate = $false,
|
2022-07-06 01:34:35 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Switch] $RunOnMetered = $false,
|
2022-06-10 08:26:41 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Switch] $Uninstall = $false,
|
2022-07-30 07:31:05 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Switch] $NoClean = $false,
|
2022-10-11 14:03:57 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Switch] $DesktopShortcut = $false,
|
|
|
|
[Parameter(Mandatory = $False)] [Switch] $StartMenuShortcut = $false,
|
2022-06-10 08:26:41 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Switch] $UseWhiteList = $false,
|
|
|
|
[Parameter(Mandatory = $False)] [ValidateSet("Full", "SuccessOnly", "None")] [String] $NotificationLevel = "Full",
|
|
|
|
[Parameter(Mandatory = $False)] [Switch] $UpdatesAtLogon = $false,
|
2022-11-24 20:05:40 +00:00
|
|
|
[Parameter(Mandatory = $False)] [ValidateSet("Daily", "BiDaily", "Weekly", "BiWeekly", "Monthly", "Never")] [String] $UpdatesInterval = "Daily",
|
2022-10-10 14:05:36 +00:00
|
|
|
[Parameter(Mandatory = $False)] [DateTime] $UpdatesAtTime = ("06am"),
|
2022-10-24 23:43:50 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Switch] $BypassListForUsers = $false,
|
2023-01-13 02:33:00 +00:00
|
|
|
[Parameter(Mandatory = $False)] [Switch] $InstallUserContext = $false,
|
2023-03-31 15:56:07 +00:00
|
|
|
[Parameter(Mandatory = $False)] [ValidateRange(0, 99)] [int32] $MaxLogFiles = 3,
|
2023-01-13 02:33:00 +00:00
|
|
|
[Parameter(Mandatory = $False)] [int64] $MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB
|
2022-02-12 15:35:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
<# FUNCTIONS #>
|
|
|
|
|
2022-06-10 08:26:41 +00:00
|
|
|
function Install-Prerequisites {
|
2022-05-29 09:39:25 +00:00
|
|
|
|
|
|
|
Write-Host "`nChecking prerequisites..." -ForegroundColor Yellow
|
2022-10-27 22:28:42 +00:00
|
|
|
|
2022-04-10 10:50:45 +00:00
|
|
|
#Check if Visual C++ 2019 or 2022 installed
|
2022-04-15 16:39:11 +00:00
|
|
|
$Visual2019 = "Microsoft Visual C++ 2015-2019 Redistributable*"
|
|
|
|
$Visual2022 = "Microsoft Visual C++ 2015-2022 Redistributable*"
|
2022-06-10 08:26:41 +00:00
|
|
|
$path = Get-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.GetValue("DisplayName") -like $Visual2019 -or $_.GetValue("DisplayName") -like $Visual2022 }
|
2022-10-27 22:28:42 +00:00
|
|
|
|
2022-02-12 15:35:51 +00:00
|
|
|
#If not installed, ask for installation
|
2022-06-10 08:26:41 +00:00
|
|
|
if (!($path)) {
|
2022-02-12 15:35:51 +00:00
|
|
|
#If -silent option, force installation
|
2022-06-10 08:26:41 +00:00
|
|
|
if ($Silent) {
|
2022-04-09 08:42:00 +00:00
|
|
|
$InstallApp = 1
|
2022-02-12 15:35:51 +00:00
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
else {
|
2022-02-12 15:35:51 +00:00
|
|
|
#Ask for installation
|
2022-04-09 08:42:00 +00:00
|
|
|
$MsgBoxTitle = "Winget Prerequisites"
|
2022-04-10 10:50:45 +00:00
|
|
|
$MsgBoxContent = "Microsoft Visual C++ 2015-2022 is required. Would you like to install it?"
|
2022-04-09 09:03:11 +00:00
|
|
|
$MsgBoxTimeOut = 60
|
2022-06-10 08:26:41 +00:00
|
|
|
$MsgBoxReturn = (New-Object -ComObject "Wscript.Shell").Popup($MsgBoxContent, $MsgBoxTimeOut, $MsgBoxTitle, 4 + 32)
|
2022-04-09 08:42:00 +00:00
|
|
|
if ($MsgBoxReturn -ne 7) {
|
|
|
|
$InstallApp = 1
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$InstallApp = 0
|
2022-02-12 15:35:51 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-09 08:42:00 +00:00
|
|
|
#Install if approved
|
2022-06-10 08:26:41 +00:00
|
|
|
if ($InstallApp -eq 1) {
|
|
|
|
try {
|
|
|
|
if ((Get-CimInStance Win32_OperatingSystem).OSArchitecture -like "*64*") {
|
2022-02-12 15:35:51 +00:00
|
|
|
$OSArch = "x64"
|
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
else {
|
2022-02-12 15:35:51 +00:00
|
|
|
$OSArch = "x86"
|
|
|
|
}
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-host "-> Downloading VC_redist.$OSArch.exe..."
|
2022-04-10 10:50:45 +00:00
|
|
|
$SourceURL = "https://aka.ms/vs/17/release/VC_redist.$OSArch.exe"
|
2022-02-12 15:35:51 +00:00
|
|
|
$Installer = $WingetUpdatePath + "\VC_redist.$OSArch.exe"
|
|
|
|
$ProgressPreference = 'SilentlyContinue'
|
2023-03-25 19:12:51 +00:00
|
|
|
Invoke-WebRequest $SourceURL -UseBasicParsing -OutFile (New-Item -Path $Installer -Force)
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-host "-> Installing VC_redist.$OSArch.exe..."
|
2022-02-26 01:07:50 +00:00
|
|
|
Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait
|
2022-02-12 15:35:51 +00:00
|
|
|
Remove-Item $Installer -ErrorAction Ignore
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-host "-> MS Visual C++ 2015-2022 installed successfully" -ForegroundColor Green
|
2022-02-12 15:35:51 +00:00
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
catch {
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-host "-> MS Visual C++ 2015-2022 installation failed." -ForegroundColor Red
|
2022-02-12 15:35:51 +00:00
|
|
|
Start-Sleep 3
|
|
|
|
}
|
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
else {
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-host "-> MS Visual C++ 2015-2022 will not be installed." -ForegroundColor Magenta
|
2022-04-09 08:42:00 +00:00
|
|
|
}
|
2022-02-12 15:35:51 +00:00
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
else {
|
2022-02-12 15:35:51 +00:00
|
|
|
Write-Host "Prerequisites checked. OK" -ForegroundColor Green
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-10 08:26:41 +00:00
|
|
|
function Install-WinGet {
|
2022-04-15 16:39:11 +00:00
|
|
|
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-Host "`nChecking if Winget is installed" -ForegroundColor Yellow
|
|
|
|
|
2022-04-15 16:39:11 +00:00
|
|
|
#Check Package Install
|
2022-06-10 08:26:41 +00:00
|
|
|
$TestWinGet = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq "Microsoft.DesktopAppInstaller" }
|
2022-05-29 09:39:25 +00:00
|
|
|
|
2023-01-26 00:20:18 +00:00
|
|
|
#Current: v1.4.10173 = 1.19.10173.0 = 2023.118.406.0
|
2023-01-25 23:50:31 +00:00
|
|
|
If ([Version]$TestWinGet.Version -ge "2023.118.406.0") {
|
2022-04-15 16:39:11 +00:00
|
|
|
|
|
|
|
Write-Host "WinGet is Installed" -ForegroundColor Green
|
2022-10-27 22:28:42 +00:00
|
|
|
|
2022-04-15 16:39:11 +00:00
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
Else {
|
2022-04-15 16:48:45 +00:00
|
|
|
|
2022-04-15 16:39:11 +00:00
|
|
|
#Download WinGet MSIXBundle
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-Host "-> Not installed. Downloading WinGet..."
|
2023-01-25 23:50:31 +00:00
|
|
|
$WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v1.4.10173/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
|
2022-06-10 08:26:41 +00:00
|
|
|
$WebClient = New-Object System.Net.WebClient
|
2022-04-15 16:39:11 +00:00
|
|
|
$WebClient.DownloadFile($WinGetURL, "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle")
|
|
|
|
|
|
|
|
#Install WinGet MSIXBundle
|
2022-06-10 08:26:41 +00:00
|
|
|
try {
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-Host "-> Installing Winget MSIXBundle for App Installer..."
|
|
|
|
Add-AppxProvisionedPackage -Online -PackagePath "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense | Out-Null
|
|
|
|
Write-Host "Installed Winget MSIXBundle for App Installer" -ForegroundColor Green
|
2022-04-15 16:39:11 +00:00
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
catch {
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-Host "Failed to intall Winget MSIXBundle for App Installer..." -ForegroundColor Red
|
2022-04-15 16:39:11 +00:00
|
|
|
}
|
2022-10-27 22:28:42 +00:00
|
|
|
|
2022-04-15 16:39:11 +00:00
|
|
|
#Remove WinGet MSIXBundle
|
|
|
|
Remove-Item -Path "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Force -ErrorAction Continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-10 08:26:41 +00:00
|
|
|
function Install-WingetAutoUpdate {
|
2022-05-29 09:39:25 +00:00
|
|
|
|
|
|
|
Write-Host "`nInstalling WAU..." -ForegroundColor Yellow
|
|
|
|
|
2022-06-10 08:26:41 +00:00
|
|
|
try {
|
2022-07-30 07:31:05 +00:00
|
|
|
#Copy files to location (and clean old install)
|
2022-06-10 08:26:41 +00:00
|
|
|
if (!(Test-Path $WingetUpdatePath)) {
|
2022-05-29 09:39:25 +00:00
|
|
|
New-Item -ItemType Directory -Force -Path $WingetUpdatePath | Out-Null
|
2022-02-12 15:35:51 +00:00
|
|
|
}
|
2022-05-29 13:47:13 +00:00
|
|
|
else {
|
2022-07-30 07:31:05 +00:00
|
|
|
if (!$NoClean) {
|
2022-07-30 13:22:34 +00:00
|
|
|
Remove-Item -Path "$WingetUpdatePath\*" -Exclude *.log -Recurse -Force
|
2022-07-30 07:31:05 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#Keep critical files
|
2022-10-18 13:23:39 +00:00
|
|
|
Get-ChildItem -Path $WingetUpdatePath -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force
|
2022-07-30 07:31:05 +00:00
|
|
|
}
|
2022-05-29 13:47:13 +00:00
|
|
|
}
|
2022-02-14 16:28:22 +00:00
|
|
|
Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue
|
2022-09-18 18:25:14 +00:00
|
|
|
|
2022-04-05 10:38:54 +00:00
|
|
|
#White List or Black List apps
|
2022-06-10 08:26:41 +00:00
|
|
|
if ($UseWhiteList) {
|
2022-07-30 13:43:45 +00:00
|
|
|
if (!$NoClean) {
|
|
|
|
if ((Test-Path "$PSScriptRoot\included_apps.txt")) {
|
|
|
|
Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue
|
|
|
|
}
|
|
|
|
else {
|
2022-10-18 13:23:39 +00:00
|
|
|
if (!$ListPath) {
|
2022-09-23 16:00:46 +00:00
|
|
|
New-Item -Path $WingetUpdatePath -Name "included_apps.txt" -ItemType "file" -ErrorAction SilentlyContinue | Out-Null
|
|
|
|
}
|
2022-07-30 13:43:45 +00:00
|
|
|
}
|
2022-04-05 10:38:54 +00:00
|
|
|
}
|
2022-07-30 13:43:45 +00:00
|
|
|
elseif (!(Test-Path "$WingetUpdatePath\included_apps.txt")) {
|
2022-08-10 15:22:39 +00:00
|
|
|
if ((Test-Path "$PSScriptRoot\included_apps.txt")) {
|
|
|
|
Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue
|
|
|
|
}
|
|
|
|
else {
|
2022-10-18 13:23:39 +00:00
|
|
|
if (!$ListPath) {
|
2022-09-23 16:00:46 +00:00
|
|
|
New-Item -Path $WingetUpdatePath -Name "included_apps.txt" -ItemType "file" -ErrorAction SilentlyContinue | Out-Null
|
|
|
|
}
|
2022-08-10 15:22:39 +00:00
|
|
|
}
|
2022-04-05 10:38:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2022-07-30 13:10:41 +00:00
|
|
|
if (!$NoClean) {
|
|
|
|
Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue
|
|
|
|
}
|
2022-08-10 15:22:39 +00:00
|
|
|
elseif (!(Test-Path "$WingetUpdatePath\excluded_apps.txt")) {
|
|
|
|
Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue
|
|
|
|
}
|
2022-04-05 10:38:54 +00:00
|
|
|
}
|
2022-02-12 15:35:51 +00:00
|
|
|
|
|
|
|
# Set dummy regkeys for notification name and icon
|
|
|
|
& reg add "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /v DisplayName /t REG_EXPAND_SZ /d "Application Update" /f | Out-Null
|
|
|
|
& reg add "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /v IconUri /t REG_EXPAND_SZ /d %SystemRoot%\system32\@WindowsUpdateToastIcon.png /f | Out-Null
|
|
|
|
|
|
|
|
# Settings for the scheduled task for Updates
|
2022-10-18 19:11:12 +00:00
|
|
|
$taskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$($WingetUpdatePath)\winget-upgrade.ps1`""
|
2022-04-30 10:00:39 +00:00
|
|
|
$taskTriggers = @()
|
2022-06-10 08:26:41 +00:00
|
|
|
if ($UpdatesAtLogon) {
|
2022-04-30 10:00:39 +00:00
|
|
|
$tasktriggers += New-ScheduledTaskTrigger -AtLogOn
|
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
if ($UpdatesInterval -eq "Daily") {
|
2022-10-05 14:43:04 +00:00
|
|
|
$tasktriggers += New-ScheduledTaskTrigger -Daily -At $UpdatesAtTime
|
2022-04-30 10:00:39 +00:00
|
|
|
}
|
2022-11-24 20:05:40 +00:00
|
|
|
elseif ($UpdatesInterval -eq "BiDaily") {
|
|
|
|
$tasktriggers += New-ScheduledTaskTrigger -Daily -At $UpdatesAtTime -DaysInterval 2
|
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
elseif ($UpdatesInterval -eq "Weekly") {
|
2022-10-05 14:43:04 +00:00
|
|
|
$tasktriggers += New-ScheduledTaskTrigger -Weekly -At $UpdatesAtTime -DaysOfWeek 2
|
2022-04-30 10:00:39 +00:00
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
elseif ($UpdatesInterval -eq "BiWeekly") {
|
2022-10-05 14:43:04 +00:00
|
|
|
$tasktriggers += New-ScheduledTaskTrigger -Weekly -At $UpdatesAtTime -DaysOfWeek 2 -WeeksInterval 2
|
2022-04-30 10:00:39 +00:00
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
elseif ($UpdatesInterval -eq "Monthly") {
|
2022-10-05 14:43:04 +00:00
|
|
|
$tasktriggers += New-ScheduledTaskTrigger -Weekly -At $UpdatesAtTime -DaysOfWeek 2 -WeeksInterval 4
|
2022-04-30 10:00:39 +00:00
|
|
|
}
|
2022-02-12 15:35:51 +00:00
|
|
|
$taskUserPrincipal = New-ScheduledTaskPrincipal -UserId S-1-5-18 -RunLevel Highest
|
|
|
|
$taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 03:00:00
|
|
|
|
|
|
|
|
# Set up the task, and register it
|
2022-04-30 10:00:39 +00:00
|
|
|
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings -Trigger $taskTriggers
|
2022-04-09 09:03:11 +00:00
|
|
|
Register-ScheduledTask -TaskName 'Winget-AutoUpdate' -InputObject $task -Force | Out-Null
|
2022-02-12 15:35:51 +00:00
|
|
|
|
2022-10-24 23:43:50 +00:00
|
|
|
if ($InstallUserContext) {
|
|
|
|
# Settings for the scheduled task in User context
|
|
|
|
$taskAction = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "`"$($WingetUpdatePath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WingetUpdatePath)\winget-upgrade.ps1`"`""
|
|
|
|
$taskUserPrincipal = New-ScheduledTaskPrincipal -GroupId S-1-5-11
|
|
|
|
$taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 03:00:00
|
2022-10-08 00:18:46 +00:00
|
|
|
|
2022-10-24 23:43:50 +00:00
|
|
|
# Set up the task for user apps
|
|
|
|
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
|
|
|
|
Register-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -InputObject $task -Force | Out-Null
|
|
|
|
}
|
2022-10-27 22:28:42 +00:00
|
|
|
|
2022-02-12 15:35:51 +00:00
|
|
|
# Settings for the scheduled task for Notifications
|
2022-10-18 19:11:12 +00:00
|
|
|
$taskAction = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "`"$($WingetUpdatePath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WingetUpdatePath)\winget-notify.ps1`"`""
|
2022-02-12 15:35:51 +00:00
|
|
|
$taskUserPrincipal = New-ScheduledTaskPrincipal -GroupId S-1-5-11
|
|
|
|
$taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 00:05:00
|
|
|
|
|
|
|
|
# Set up the task, and register it
|
|
|
|
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
|
2022-04-09 09:03:11 +00:00
|
|
|
Register-ScheduledTask -TaskName 'Winget-AutoUpdate-Notify' -InputObject $task -Force | Out-Null
|
2022-02-12 15:35:51 +00:00
|
|
|
|
2022-10-08 00:18:46 +00:00
|
|
|
#Set task readable/runnable for all users
|
|
|
|
$scheduler = New-Object -ComObject "Schedule.Service"
|
|
|
|
$scheduler.Connect()
|
|
|
|
$task = $scheduler.GetFolder("").GetTask("Winget-AutoUpdate")
|
|
|
|
$sec = $task.GetSecurityDescriptor(0xF)
|
|
|
|
$sec = $sec + '(A;;GRGX;;;AU)'
|
|
|
|
$task.SetSecurityDescriptor($sec, 0)
|
|
|
|
|
2022-05-22 13:27:45 +00:00
|
|
|
# Configure Reg Key
|
|
|
|
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
|
2022-05-29 09:39:25 +00:00
|
|
|
New-Item $regPath -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name DisplayIcon -Value "C:\Windows\System32\shell32.dll,-16739" -Force | Out-Null
|
2022-05-30 16:31:48 +00:00
|
|
|
New-ItemProperty $regPath -Name DisplayVersion -Value $WAUVersion -Force | Out-Null
|
2022-05-29 09:39:25 +00:00
|
|
|
New-ItemProperty $regPath -Name InstallLocation -Value $WingetUpdatePath -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name UninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WingetUpdatePath\WAU-Uninstall.ps1`"" -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name QuietUninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WingetUpdatePath\WAU-Uninstall.ps1`"" -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name NoModify -Value 1 -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name NoRepair -Value 1 -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name Publisher -Value "Romanitho" -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name URLInfoAbout -Value "https://github.com/Romanitho/Winget-AutoUpdate" -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $NotificationLevel -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name WAU_PostUpdateActions -Value 0 -PropertyType DWord -Force | Out-Null
|
2023-01-13 02:33:00 +00:00
|
|
|
New-ItemProperty $regPath -Name WAU_MaxLogFiles -Value $MaxLogFiles -PropertyType DWord -Force | Out-Null
|
|
|
|
New-ItemProperty $regPath -Name WAU_MaxLogSize -Value $MaxLogSize -PropertyType DWord -Force | Out-Null
|
2022-05-29 09:39:25 +00:00
|
|
|
if ($DisableWAUAutoUpdate) {
|
|
|
|
New-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Value 1 -Force | Out-Null
|
|
|
|
}
|
|
|
|
if ($UseWhiteList) {
|
|
|
|
New-ItemProperty $regPath -Name WAU_UseWhiteList -Value 1 -PropertyType DWord -Force | Out-Null
|
|
|
|
}
|
2022-06-29 15:32:03 +00:00
|
|
|
if (!$RunOnMetered) {
|
|
|
|
New-ItemProperty $regPath -Name WAU_DoNotRunOnMetered -Value 1 -PropertyType DWord -Force | Out-Null
|
|
|
|
}
|
2022-10-18 13:23:39 +00:00
|
|
|
if ($ListPath) {
|
2022-10-11 14:03:57 +00:00
|
|
|
New-ItemProperty $regPath -Name WAU_ListPath -Value $ListPath -Force | Out-Null
|
2022-09-25 14:54:58 +00:00
|
|
|
}
|
2022-11-02 17:47:21 +00:00
|
|
|
if ($ModsPath) {
|
|
|
|
New-ItemProperty $regPath -Name WAU_ModsPath -Value $ModsPath -Force | Out-Null
|
|
|
|
}
|
2023-03-07 15:17:40 +00:00
|
|
|
if ($AzureBlobSASURL) {
|
|
|
|
New-ItemProperty $regPath -Name WAU_AzureBlobSASURL -Value $AzureBlobSASURL -Force | Out-Null
|
|
|
|
}
|
2022-10-18 13:23:39 +00:00
|
|
|
if ($BypassListForUsers) {
|
2022-10-10 14:05:36 +00:00
|
|
|
New-ItemProperty $regPath -Name WAU_BypassListForUsers -Value 1 -PropertyType DWord -Force | Out-Null
|
|
|
|
}
|
2022-05-29 09:39:25 +00:00
|
|
|
|
2023-03-03 19:15:59 +00:00
|
|
|
#Log file and symlink initialization
|
|
|
|
. "$WingetUpdatePath\functions\Start-Init.ps1"
|
|
|
|
Start-Init
|
2022-10-12 20:07:47 +00:00
|
|
|
|
2023-02-06 06:47:06 +00:00
|
|
|
#Security check
|
|
|
|
Write-host "`nChecking Mods Directory:" -ForegroundColor Yellow
|
|
|
|
. "$WingetUpdatePath\functions\Invoke-ModsProtect.ps1"
|
|
|
|
$Protected = Invoke-ModsProtect "$WingetUpdatePath\mods"
|
2023-02-07 19:06:54 +00:00
|
|
|
if ($Protected -eq $True) {
|
2023-02-06 06:47:06 +00:00
|
|
|
Write-Host "The mods directory is now secured!`n" -ForegroundColor Green
|
2023-02-04 23:10:32 +00:00
|
|
|
}
|
2023-02-07 19:06:54 +00:00
|
|
|
elseif ($Protected -eq $False) {
|
2023-02-06 06:47:06 +00:00
|
|
|
Write-Host "The mods directory was already secured!`n" -ForegroundColor Green
|
2023-02-04 23:10:32 +00:00
|
|
|
}
|
2023-02-07 19:06:54 +00:00
|
|
|
else {
|
|
|
|
Write-Host "Error: The mods directory couldn't be verified as secured!`n" -ForegroundColor Red
|
|
|
|
}
|
2023-03-31 15:56:07 +00:00
|
|
|
|
2022-10-11 14:03:57 +00:00
|
|
|
#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)..."
|
|
|
|
}
|
|
|
|
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-host "WAU Installation succeeded!" -ForegroundColor Green
|
2022-02-12 15:35:51 +00:00
|
|
|
Start-sleep 1
|
2022-10-27 22:28:42 +00:00
|
|
|
|
2022-02-12 15:35:51 +00:00
|
|
|
#Run Winget ?
|
|
|
|
Start-WingetAutoUpdate
|
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
catch {
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-host "WAU Installation failed! Run me with admin rights" -ForegroundColor Red
|
2022-02-12 15:35:51 +00:00
|
|
|
Start-sleep 1
|
|
|
|
return $False
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-10 08:26:41 +00:00
|
|
|
function Uninstall-WingetAutoUpdate {
|
2022-10-27 22:28:42 +00:00
|
|
|
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-Host "`nUninstalling WAU..." -ForegroundColor Yellow
|
2022-10-27 22:28:42 +00:00
|
|
|
|
2022-06-10 08:26:41 +00:00
|
|
|
try {
|
2022-05-22 15:24:56 +00:00
|
|
|
#Get registry install location
|
|
|
|
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
|
2022-10-27 22:28:42 +00:00
|
|
|
|
2022-07-30 07:31:05 +00:00
|
|
|
#Check if installed location exists and delete
|
2022-06-10 08:26:41 +00:00
|
|
|
if (Test-Path ($InstallLocation)) {
|
2022-07-30 07:31:05 +00:00
|
|
|
|
|
|
|
if (!$NoClean) {
|
2022-07-30 13:22:34 +00:00
|
|
|
Remove-Item $InstallLocation -Force -Recurse
|
2023-03-03 19:15:59 +00:00
|
|
|
if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log") {
|
|
|
|
Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -Force -ErrorAction SilentlyContinue | Out-Null
|
|
|
|
}
|
2023-05-03 06:13:58 +00:00
|
|
|
if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log") {
|
|
|
|
Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -Force -ErrorAction SilentlyContinue | Out-Null
|
|
|
|
}
|
2022-07-30 07:31:05 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#Keep critical files
|
2022-10-18 13:23:39 +00:00
|
|
|
Get-ChildItem -Path $InstallLocation -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force
|
2022-07-30 07:31:05 +00:00
|
|
|
}
|
2022-04-02 17:24:18 +00:00
|
|
|
Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
|
2022-10-08 00:18:46 +00:00
|
|
|
Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
|
|
|
|
Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
|
2022-04-02 17:24:18 +00:00
|
|
|
& reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null
|
2022-05-22 15:24:56 +00:00
|
|
|
& reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
|
2022-10-27 22:28:42 +00:00
|
|
|
|
2022-10-11 14:03:57 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-04-02 17:24:18 +00:00
|
|
|
Write-host "Uninstallation succeeded!" -ForegroundColor Green
|
|
|
|
Start-sleep 1
|
|
|
|
}
|
|
|
|
else {
|
2022-05-22 15:24:56 +00:00
|
|
|
Write-host "$InstallLocation not found! Uninstallation failed!" -ForegroundColor Red
|
2022-04-02 17:24:18 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
catch {
|
2022-05-30 16:31:48 +00:00
|
|
|
Write-host "Uninstallation failed! Run as admin ?" -ForegroundColor Red
|
2022-04-02 17:24:18 +00:00
|
|
|
Start-sleep 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-10 08:26:41 +00:00
|
|
|
function Start-WingetAutoUpdate {
|
2022-02-12 15:35:51 +00:00
|
|
|
#If -DoNotUpdate is true, skip.
|
2022-06-10 08:26:41 +00:00
|
|
|
if (!($DoNotUpdate)) {
|
|
|
|
#If -Silent, run Winget-AutoUpdate now
|
|
|
|
if ($Silent) {
|
|
|
|
$RunWinget = 1
|
|
|
|
}
|
|
|
|
#Ask for WingetAutoUpdate
|
|
|
|
else {
|
|
|
|
$MsgBoxTitle = "Winget-AutoUpdate"
|
|
|
|
$MsgBoxContent = "Would you like to run Winget-AutoUpdate now?"
|
|
|
|
$MsgBoxTimeOut = 60
|
|
|
|
$MsgBoxReturn = (New-Object -ComObject "Wscript.Shell").Popup($MsgBoxContent, $MsgBoxTimeOut, $MsgBoxTitle, 4 + 32)
|
|
|
|
if ($MsgBoxReturn -ne 7) {
|
2022-04-09 08:42:00 +00:00
|
|
|
$RunWinget = 1
|
2022-02-12 15:35:51 +00:00
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
else {
|
|
|
|
$RunWinget = 0
|
2022-02-12 15:35:51 +00:00
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
}
|
|
|
|
if ($RunWinget -eq 1) {
|
|
|
|
try {
|
2022-05-30 16:31:48 +00:00
|
|
|
Write-host "`nRunning Winget-AutoUpdate..." -ForegroundColor Yellow
|
2022-02-14 16:28:22 +00:00
|
|
|
Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue
|
2022-06-10 08:26:41 +00:00
|
|
|
while ((Get-ScheduledTask -TaskName "Winget-AutoUpdate").State -ne 'Ready') {
|
2022-04-02 17:24:18 +00:00
|
|
|
Start-Sleep 1
|
|
|
|
}
|
2022-02-12 15:35:51 +00:00
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
catch {
|
2022-02-12 15:35:51 +00:00
|
|
|
Write-host "Failed to run Winget-AutoUpdate..." -ForegroundColor Red
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-10 08:26:41 +00:00
|
|
|
else {
|
2022-02-12 15:35:51 +00:00
|
|
|
Write-host "Skip running Winget-AutoUpdate"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-11 14:03:57 +00:00
|
|
|
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()
|
|
|
|
}
|
2022-02-12 15:35:51 +00:00
|
|
|
|
2023-04-12 14:25:56 +00:00
|
|
|
|
|
|
|
<# APP INFO #>
|
|
|
|
|
|
|
|
$WAUVersion = Get-Content "$PSScriptRoot\Winget-AutoUpdate\Version.txt" -ErrorAction SilentlyContinue
|
|
|
|
|
|
|
|
|
2022-02-12 15:35:51 +00:00
|
|
|
<# MAIN #>
|
|
|
|
|
2022-10-27 22:28:42 +00:00
|
|
|
#If running as a 32-bit process on an x64 system, re-launch as a 64-bit process
|
|
|
|
if ("$env:PROCESSOR_ARCHITEW6432" -ne "ARM64") {
|
|
|
|
if (Test-Path "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe") {
|
|
|
|
Start-Process "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe" -Wait -NoNewWindow -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command $($MyInvocation.line)"
|
|
|
|
Exit $lastexitcode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-03 10:40:44 +00:00
|
|
|
Write-Host "`n"
|
2022-06-03 13:54:35 +00:00
|
|
|
Write-Host "`t 888 888 d8888 888 888" -ForegroundColor Magenta
|
|
|
|
Write-Host "`t 888 o 888 d88888 888 888" -ForegroundColor Magenta
|
|
|
|
Write-Host "`t 888 d8b 888 d88P888 888 888" -ForegroundColor Magenta
|
|
|
|
Write-Host "`t 888 d888b 888 d88P 888 888 888" -ForegroundColor Magenta
|
2022-06-03 14:07:22 +00:00
|
|
|
Write-Host "`t 888d88888b888 d88P 888 888 888" -ForegroundColor Magenta
|
|
|
|
Write-Host "`t 88888P Y88888 d88P 888 888 888" -ForegroundColor Cyan
|
|
|
|
Write-Host "`t 8888P Y8888 d88P 888 888 888" -ForegroundColor Magenta
|
2022-06-03 13:54:35 +00:00
|
|
|
Write-Host "`t 888P Y888 d88P 888 Y8888888P`n" -ForegroundColor Magenta
|
2022-05-30 16:34:26 +00:00
|
|
|
Write-Host "`t Winget-AutoUpdate $WAUVersion`n" -ForegroundColor Cyan
|
2022-05-29 16:00:22 +00:00
|
|
|
Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -ForegroundColor Magenta
|
|
|
|
Write-Host "`t________________________________________________________`n`n"
|
2022-02-12 15:35:51 +00:00
|
|
|
|
2022-06-10 08:26:41 +00:00
|
|
|
if (!$Uninstall) {
|
2022-04-09 08:42:00 +00:00
|
|
|
Write-host "Installing WAU to $WingetUpdatePath\"
|
2022-04-02 17:24:18 +00:00
|
|
|
Install-Prerequisites
|
2022-04-15 16:39:11 +00:00
|
|
|
Install-WinGet
|
2022-04-02 17:24:18 +00:00
|
|
|
Install-WingetAutoUpdate
|
|
|
|
}
|
|
|
|
else {
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-Host "Uninstalling WAU..."
|
2022-04-02 17:24:18 +00:00
|
|
|
Uninstall-WingetAutoUpdate
|
|
|
|
}
|
2022-02-12 15:35:51 +00:00
|
|
|
|
2023-04-12 14:39:24 +00:00
|
|
|
Remove-Item "$WingetUpdatePath\Version.txt" -Force
|
2022-05-29 09:39:25 +00:00
|
|
|
Write-host "`nEnd of process." -ForegroundColor Cyan
|
2022-10-08 00:18:46 +00:00
|
|
|
Start-Sleep 3
|