diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml
index 1e59ebe..c4429c9 100644
--- a/.github/workflows/WAU-AutoCreatePreVersion.yml
+++ b/.github/workflows/WAU-AutoCreatePreVersion.yml
@@ -92,8 +92,8 @@ jobs:
zip -r WAU.zip Winget-AutoUpdate
zip WAU.zip Winget-AutoUpdate-Install.ps1
zip WAU.zip excluded_apps.txt
- zip WAU.zip install.bat
- zip WAU.zip uninstall.bat
+ zip WAU.zip Gui.ps1
+ zip WAU.zip "WAU Configurator.lnk"
# Zip ADMX
cd Policies
zip -r ../WAU_ADMX.zip *
diff --git a/.github/workflows/WAU-CreateNewVersion.yml b/.github/workflows/WAU-CreateNewVersion.yml
index 00e85a0..ec60dad 100644
--- a/.github/workflows/WAU-CreateNewVersion.yml
+++ b/.github/workflows/WAU-CreateNewVersion.yml
@@ -65,8 +65,8 @@ jobs:
zip -r WAU.zip Winget-AutoUpdate
zip WAU.zip Winget-AutoUpdate-Install.ps1
zip WAU.zip excluded_apps.txt
- zip WAU.zip install.bat
- zip WAU.zip uninstall.bat
+ zip WAU.zip Gui.ps1
+ zip WAU.zip "WAU Configurator.lnk"
# Zip ADMX
cd Policies
zip -r ../WAU_ADMX.zip *
diff --git a/Gui.ps1 b/Gui.ps1
new file mode 100644
index 0000000..9b4e9f8
--- /dev/null
+++ b/Gui.ps1
@@ -0,0 +1,785 @@
+<#
+.SYNOPSIS
+Install and configure Winget-AutoUpdate
+
+.DESCRIPTION
+This script will:
+ - Install Winget if not present
+ - Install Winget-AutoUpdate to get apps daily updated
+ - Install apps with Winget from a custom list file (apps.txt) or directly from popped up default list.
+#>
+
+<# APP INFO #>
+
+# import Appx module if the powershell version is 7/core
+if ( $psversionTable.PSEdition -eq "core" ) {
+ import-Module -name Appx -UseWIndowsPowershell -WarningAction:SilentlyContinue
+}
+
+$Script:WAUConfiguratorVersion = Get-Content "$PSScriptRoot\Winget-AutoUpdate\Version.txt"
+
+
+<# FUNCTIONS #>
+
+. "$PSScriptRoot\Winget-AutoUpdate\functions\Update-WinGet.ps1"
+. "$PSScriptRoot\Winget-AutoUpdate\functions\Get-WingetCmd.ps1"
+
+#Function to start or update popup
+Function Start-PopUp ($Message) {
+
+ if (!$PopUpWindow) {
+
+ #Create window
+ $inputXML = @"
+
+
+
+
+
+"@
+
+ [xml]$XAML = ($inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^ Removing admin rights for user context apps
+ }
+
+
+ ## ADMIN PART ##
+
+ if ($CMTrace) {
+ Start-PopUp "Installing CMTrace..."
+ $CMToolkitLink = "https://github.com/Romanitho/Winget-Install-GUI/raw/main/Tools/cmtrace.exe"
+ $CMToolkitPath = "C:\Tools\CMTrace.exe"
+ Invoke-WebRequest $CMToolkitLink -OutFile (New-Item -Path $CMToolkitPath -Force)
+ Start-Sleep 1
+ }
+
+ if ($AdvancedRun) {
+ Start-PopUp "Installing AdvancedRun..."
+ $AdvancedRunLink = "https://www.nirsoft.net/utils/advancedrun-x64.zip"
+ $AdvancedRunPath = "C:\Tools\advancedrun-x64.zip"
+ Invoke-WebRequest $AdvancedRunLink -OutFile (New-Item -Path $AdvancedRunPath -Force)
+ Expand-Archive -Path $AdvancedRunPath -DestinationPath "C:\Tools\AdvancedRun" -Force
+ Start-Sleep 1
+ Remove-Item $AdvancedRunPath
+ }
+
+ if ($UninstallView) {
+ Start-PopUp "Installing UninstallView..."
+ $UninstallViewLink = "https://www.nirsoft.net/utils/uninstallview-x64.zip"
+ $UninstallViewPath = "C:\Tools\uninstallview-x64.zip"
+ Invoke-WebRequest $UninstallViewLink -OutFile (New-Item -Path $UninstallViewPath -Force)
+ Expand-Archive -Path $UninstallViewPath -DestinationPath "C:\Tools\UninstallView" -Force
+ Start-Sleep 1
+ Remove-Item $UninstallViewPath
+ }
+
+ #If Popup Form is showing, close
+ if ($PopUpWindow) {
+ #Installs finished
+ Start-PopUp "Done!"
+ Start-Sleep 1
+ #Close Popup
+ Close-PopUp
+ }
+
+ if ($CMTrace -or $AdvancedRun -or $UninstallView) {
+ Start-Process "C:\Tools"
+ }
+}
+
+function Start-Uninstallations ($AppToUninstall) {
+ #Download and run Winget-Install script if box is checked
+ if ($AppToUninstall) {
+
+ Start-PopUp "Uninstalling applications..."
+
+ #Run Winget-Install -Uninstall
+ $AppsToUninstall = "'$($AppToUninstall -join "','")'"
+ Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command `"$PSScriptRoot\Winget-AutoUpdate\Winget-Install.ps1 -AppIDs $AppsToUninstall -Uninstall`"" -Wait -Verb RunAs
+
+ Close-PopUp
+ }
+}
+
+function Get-WAUInstallStatus {
+ $WAUVersion = Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\ -ErrorAction SilentlyContinue | Select-Object -ExpandProperty DisplayVersion -ErrorAction SilentlyContinue
+ if ($WAUVersion -eq $WAUConfiguratorVersion) {
+ $WAULabelText = "WAU is currently installed (v$WAUVersion)."
+ $WAUStatus = "Green"
+ $WAUInstalled = $true
+ }
+ elseif ($WAUVersion) {
+ $WAULabelText = "WAU is currently installed (v$WAUVersion) but in another version!"
+ $WAUStatus = "Orange"
+ $WAUInstalled = $true
+ }
+ else {
+ $WAULabelText = "WAU is not installed."
+ $WAUStatus = "Red"
+ $WAUInstalled = $false
+ }
+ return $WAULabelText, $WAUStatus, $WAUInstalled
+}
+
+function Get-WAUConfiguratorLatestVersion {
+
+ ### FORM CREATION ###
+
+ #Get latest stable info
+ $WAUConfiguratorURL = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest'
+ $WAUConfiguratorLatestVersion = (((Invoke-WebRequest $WAUConfiguratorURL -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")).Replace("-", ".")
+
+ if ([version]$WAUConfiguratorVersion -lt [version]$WAUConfiguratorLatestVersion) {
+
+ #Create window
+ $inputXML = @"
+
+
+
+
+
+
+
+
+
+
+"@
+
+ [xml]$XAML = ($inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ More info about WAU
+
+
+
+"@
+
+ #Create window
+ [xml]$XAML = ($inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^
+
+#Load assemblies
+Add-Type -AssemblyName System.Windows.Forms
+Add-Type -AssemblyName System.Drawing
+Add-Type -AssemblyName PresentationFramework
+
+#Set some variables
+$null = cmd /c ''
+[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
+$Script:ProgressPreference = "SilentlyContinue"
+$Script:ErrorActionPreference = "SilentlyContinue"
+$Script:AppToInstall = $null
+$Script:InstallWAU = $null
+$IconBase64 = [Convert]::FromBase64String("AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAAMMOAADDDgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA39DIHd7Qx2Pdz8ec3c7FzNzOxezczcT/283E/9vNxOzbzcTQ3M7EoNzOxWDcz8QeAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA39LLNd7RyZne0Mjq39LK/+PY0f/p4Nv/7ebh/+/p5v/v6eb/7eXh/+je2f/i1s//3dDH/9zNxO7czsSd3M/GLwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4NLNEODTzIzf0sry4tbP/+3n4v/39fP//v39//////////////////////////////////38/P/39PL/7OTg/+HUzf/czcT03M7Gid3Pxw4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAODUzSrg08zM4dXN/+3m4v/7+fj/////////////////////////////////////////////////////////////////+/r5/+vk3//e0Mj/3M7FzNzPxi0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADh1s864dTN4eXb1f/38/H///////////////////////////////////////////////////////////////////////////////////////Xx7//i1s//3M7G4d7QyDoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA49bPLeLVzuHn3df/+vn4//////////////////////////////////////////////////////////////////////////////////////////////////r49//j2NH/3M/G4d3RxyoAAAAAAAAAAAAAAAAAAAAAAAAAAOLa0Q7i18/M5tzW//v5+P/////////////////////////////////+/Pr/9+ja/+/Uv//szLz/7My7/+/Sv//25tf//vv5//////////////////////////////////r49//j19D/3c/HzN/QyRAAAAAAAAAAAAAAAAAAAAAA49nSieTa0//39PL////////////////////////////+/fv/8Na+/+Ciav/XfwD/1HAA/9JoAP/RZgD/0mwA/9V5AP/dm2L/79S////9+/////////////////////7///////bz8P/f0sv/39HJjAAAAAAAAAAAAAAAAOPa0y/k2dH07+rm////////////////////////////+/Ts/+Sxhf/WeAD/1XUA/9uPPv/krnv/6cGk/+nBpP/jrXz/2ow9/9NuAP/TbwD/462E//ry6f//////9+ng/+Wzif/47OL//////+3m4f/e0Mjy3tLLNQAAAAAAAAAA5drTnejf2f/8+/v///////////////////////vz6v/ho2P/1ncA/9yQOf/u0Lb//Pbw///+/P/////////////+/P/79e7/7c61/9qLOv/SagD/3pth//348f/rzL3/zlMA/+vKuf//////+/n4/+LWz//f0sqZAAAAAOXc1B7l29Tu8evn/////////////////////////fv/5rWG/9d5AP/gnVT/+e3h////////////////////////////////////////////+Ozh/92WUf/SbAD/5bSQ/+rItf/QYQD/68q7////////////7ufj/9/Syurg08sd5tzWYOfd1//59/b///////////////////////HXv//ZgAD/3pU9//nt4f//////////////////////////////////////////////////////+Ozh/9qKOf/WfAD/3JNL/9JtAP/ry7z////////////49fP/4dXO/+HUzGPm3dag6uLd//79/f////////////////////7/6b2P/9l7AP/w07j/////////////////////////////////////////////////////////////////79K5/9V4AP/VewD/03EA/+vLvP////////////79/f/l29X/4NTMnOfd19Dv6OT////////////////////////////68Ob/89rD//779//////////////////////////////////////////////////57eP/68ar/+rFqf/ou5f/2IMa/9Z+AP/UcwD/68u7/////////////////+vj3//g1MzM6N7Y7PLt6////////////////////////////////////////////////////////////////////////////////////////////+m+lf/TaAD/1G8A/9RwAP/WdwD/1XYA/9NsAP/tzrz/////////////////7+nl/+HVzezo39n/9PDu////////////////////////////////////////////////////////////////////////////////////////////+e7k/+3Puv/tzrz/7c28/+3NvP/szbv/7s+8//vz6//////////////////y7On/4tXO/+ng2v/18e7//////////////////PXs//HVvf/v0rz/79K8/+/SvP/v0bz/79K6//rv5f////////////////////////////////////////////////////////////////////////////////////////////Lt6v/i18//6eHb7PPv7P/////////////////x1bz/3IgA/92MAP/diwD/24UA/9uCAP/ZewD/68OX////////////////////////////////////////////////////////////////////////////////////////////8Orn/+PX0Ozq4dzM8ezo//////////////////DTvP/ekAD/35YQ/+CYJP/sxJr/7syr/+7Mrf/57uP//////////////////////////////////////////////////vv3//LZw//67+b////////////////////////////t5uH/5NjS0Ovi3Zzu5+P//v7+////////////8dS8/9+SAP/glgD/35MA//LZvP/////////////////////////////////////////////////////////////////w07j/2HkA/+m8jv////7//////////////////v39/+ng2v/l2tOg7OTfY+zk4P/7+Pf////////////x1bz/35IA/+WqU//hmQb/46JA//rv4v//////////////////////////////////////////////////////+e7i/9+ZPv/agwD/8de////////////////////////59/X/5tzW/+Xb1WDs5OAd7OTf6vXw7v////////////HVvP/fjwD/8NO2/+zDlP/fkAD/5qxZ//rw4v////////////////////////////////////////////ru4v/ipFb/2oIA/+i3h////fv///////////////////////Hs6P/m3NXu5dzVHgAAAADs5eCZ7ufj//38+///////8dW6/96KAP/x1r7//fry/+eyaP/fkAD/5KRD//LXuP/89+/////9//////////////79//z38f/x1bj/4Zw9/9uFAP/kqmX/+/Tq///////////////////////8/Pv/6uHc/+bd150AAAAAAAAAAO3m4jXt5eHx9fHu///////68OT/7caQ//nu4f///////PXr/+vAif/glQD/35IA/+SlRv/qvYH/7sum/+7Lpv/pu4D/4qBE/92LAP/djAD/6bqI//z17P////////////////////////////Ls6f/n3df0593XLwAAAAAAAAAAAAAAAO3n44zu5+P/+vj3//////////////////////////////78//Tewv/os2n/4ZsA/9+RAP/ejAD/3YoA/96PAP/glwD/57Fu//PbwP///fz////////////////////////////49vT/6eDb/+nf2YkAAAAAAAAAAAAAAAAAAAAA7OnjEO7n48zw6uf//Pv7//////////////////////////////////78+f/57Nr/89zB//HVvP/x1bz/89zB//ns3P/+/fr//////////////////////////////////Pr5/+zl4P/p4NrM6ODYDgAAAAAAAAAAAAAAAAAAAAAAAAAA7+nlKe7n4+Dx6+j//Pv7//////////////////////////////////////////////////////////////////////////////////////////////////z7+v/u5+L/6eHb4evi2ywAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7+nlOu/o5OHx6+j/+vj3///////////////////////////////////////////////////////////////////////////////////////59/b/7ufi/+ri3eDr4906AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8OrmLO/p5czw6eb/9vLw//38/P/////////////////////////////////////////////////////////////////9/Pv/9PDt/+zl4P/r497M6+XeKQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8enpDvDq5onv6eX08ezo//by8P/7+vn//v7+//////////////////////////////////7+/v/7+fj/9fHv/+7o4//s5ODx7OTgjOvj3xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPHq5i/w6uWc7+nl7vDq5v/y7On/9PDt//bz8P/39PL/9/Ty//by8P/07+z/8Orn/+7n4//t5uHq7OXhmezl4TUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADw6+Ue8OrmYO/p5aDv6eXQ7+jl7O/o5P/u6OT/7ujk7O7n48zu5+Kc7efjY+zl5B0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/8AD//8AAP/8AAA/+AAAH/AAAA/gAAAHwAAAA8AAAAOAAAABgAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAGAAAABwAAAA8AAAAPgAAAH8AAAD/gAAB/8AAA//wAA///AA/8=")
+
+Start-PopUp "Starting..."
+
+#Check if WAUConfigurator is uptodate
+Get-WAUConfiguratorLatestVersion
+
+#Check if Winget is installed, and install if not
+Update-WinGet
+
+#Get WinGet cmd
+$Script:Winget = Get-WingetCmd
+
+#Run WAUConfigurator
+Close-PopUp
+Start-InstallGUI
diff --git a/WAU Configurator.lnk b/WAU Configurator.lnk
new file mode 100644
index 0000000..b9e20e7
Binary files /dev/null and b/WAU Configurator.lnk differ
diff --git a/Winget-AutoUpdate/Winget-Install.ps1 b/Winget-AutoUpdate/Winget-Install.ps1
new file mode 100644
index 0000000..be669cf
--- /dev/null
+++ b/Winget-AutoUpdate/Winget-Install.ps1
@@ -0,0 +1,407 @@
+<#
+.SYNOPSIS
+Install apps with Winget through Intune or SCCM.
+Can be used standalone.
+
+.DESCRIPTION
+Allow to run Winget in System Context to install your apps.
+https://github.com/Romanitho/Winget-Install
+
+.PARAMETER AppIDs
+Forward Winget App ID to install. For multiple apps, separate with ",". Case sensitive.
+
+.PARAMETER Uninstall
+To uninstall app. Works with AppIDs
+
+.PARAMETER LogPath
+Used to specify logpath. Default is same folder as Winget-Autoupdate project
+
+.PARAMETER WAUWhiteList
+Adds the app to the Winget-AutoUpdate White List. More info: https://github.com/Romanitho/Winget-AutoUpdate
+If '-Uninstall' is used, it removes the app from WAU White List.
+
+.EXAMPLE
+.\winget-install.ps1 -AppIDs 7zip.7zip
+
+.EXAMPLE
+.\winget-install.ps1 -AppIDs 7zip.7zip -Uninstall
+
+.EXAMPLE
+.\winget-install.ps1 -AppIDs 7zip.7zip -WAUWhiteList
+
+.EXAMPLE
+.\winget-install.ps1 -AppIDs 7zip.7zip,Notepad++.Notepad++ -LogPath "C:\temp\logs"
+
+.EXAMPLE
+.\winget-install.ps1 -AppIDs "7zip.7zip -v 22.00", "Notepad++.Notepad++"
+#>
+
+[CmdletBinding()]
+param(
+ [Parameter(Mandatory = $True, ParameterSetName = "AppIDs")] [String[]] $AppIDs,
+ [Parameter(Mandatory = $False)] [Switch] $Uninstall,
+ [Parameter(Mandatory = $False)] [String] $LogPath,
+ [Parameter(Mandatory = $False)] [Switch] $WAUWhiteList
+)
+
+
+<# FUNCTIONS #>
+
+#Include external Functions
+. "$PSScriptRoot\functions\Install-Prerequisites.ps1"
+. "$PSScriptRoot\functions\Update-WinGet.ps1"
+. "$PSScriptRoot\functions\Update-StoreApps.ps1"
+. "$PSScriptRoot\functions\Add-ScopeMachine.ps1"
+. "$PSScriptRoot\functions\Get-WingetCmd.ps1"
+. "$PSScriptRoot\functions\Write-ToLog.ps1"
+. "$PSScriptRoot\functions\Confirm-Installation.ps1"
+
+
+#Check if App exists in Winget Repository
+function Confirm-Exist ($AppID) {
+ #Check is app exists in the winget repository
+ $WingetApp = & $winget show --Id $AppID -e --accept-source-agreements -s winget | Out-String
+
+ #Return if AppID exists
+ if ($WingetApp -match [regex]::Escape($AppID)) {
+ Write-ToLog "-> $AppID exists on Winget Repository." "Cyan"
+ return $true
+ }
+ else {
+ Write-ToLog "-> $AppID does not exist on Winget Repository! Check spelling." "Red"
+ return $false
+ }
+}
+
+#Check if install modifications exist in "mods" directory
+function Test-ModsInstall ($AppID) {
+ if (Test-Path "$PSScriptRoot\mods\$AppID-preinstall.ps1") {
+ $ModsPreInstall = "$PSScriptRoot\mods\$AppID-preinstall.ps1"
+ }
+ elseif (($WAUInstallLocation) -and (Test-Path "$WAUInstallLocation\mods\$AppID-preinstall.ps1")) {
+ $ModsPreInstall = "$WAUInstallLocation\mods\$AppID-preinstall.ps1"
+ }
+
+ if (Test-Path "$PSScriptRoot\mods\$AppID-install.ps1") {
+ $ModsInstall = "$PSScriptRoot\mods\$AppID-install.ps1"
+ }
+ elseif (($WAUInstallLocation) -and (Test-Path "$WAUInstallLocation\mods\$AppID-install.ps1")) {
+ $ModsInstall = "$WAUInstallLocation\mods\$AppID-install.ps1"
+ }
+
+ if (Test-Path "$PSScriptRoot\mods\$AppID-installed-once.ps1") {
+ $ModsInstalledOnce = "$PSScriptRoot\mods\$AppID-installed-once.ps1"
+ }
+
+ if (Test-Path "$PSScriptRoot\mods\$AppID-installed.ps1") {
+ $ModsInstalled = "$PSScriptRoot\mods\$AppID-installed.ps1"
+ }
+ elseif (($WAUInstallLocation) -and (Test-Path "$WAUInstallLocation\mods\$AppID-installed.ps1")) {
+ $ModsInstalled = "$WAUInstallLocation\mods\$AppID-installed.ps1"
+ }
+
+ return $ModsPreInstall, $ModsInstall, $ModsInstalledOnce, $ModsInstalled
+}
+
+#Check if uninstall modifications exist in "mods" directory
+function Test-ModsUninstall ($AppID) {
+ if (Test-Path "$PSScriptRoot\mods\$AppID-preuninstall.ps1") {
+ $ModsPreUninstall = "$PSScriptRoot\mods\$AppID-preuninstall.ps1"
+ }
+ elseif (($WAUInstallLocation) -and (Test-Path "$WAUInstallLocation\mods\$AppID-preuninstall.ps1")) {
+ $ModsPreUninstall = "$WAUInstallLocation\mods\$AppID-preuninstall.ps1"
+ }
+
+ if (Test-Path "$PSScriptRoot\mods\$AppID-uninstall.ps1") {
+ $ModsUninstall = "$PSScriptRoot\mods\$AppID-uninstall.ps1"
+ }
+ elseif (($WAUInstallLocation) -and (Test-Path "$WAUInstallLocation\mods\$AppID-uninstall.ps1")) {
+ $ModsUninstall = "$WAUInstallLocation\mods\$AppID-uninstall.ps1"
+ }
+
+ if (Test-Path "$PSScriptRoot\mods\$AppID-uninstalled.ps1") {
+ $ModsUninstalled = "$PSScriptRoot\mods\$AppID-uninstalled.ps1"
+ }
+ elseif (($WAUInstallLocation) -and (Test-Path "$WAUInstallLocation\mods\$AppID-uninstalled.ps1")) {
+ $ModsUninstalled = "$WAUInstallLocation\mods\$AppID-uninstalled.ps1"
+ }
+
+ return $ModsPreUninstall, $ModsUninstall, $ModsUninstalled
+}
+
+#Install function
+function Install-App ($AppID, $AppArgs) {
+ $IsInstalled = Confirm-Installation $AppID
+ if (!($IsInstalled)) {
+ #Check if mods exist (or already exist) for preinstall/install/installedonce/installed
+ $ModsPreInstall, $ModsInstall, $ModsInstalledOnce, $ModsInstalled = Test-ModsInstall $($AppID)
+
+ #If PreInstall script exist
+ if ($ModsPreInstall) {
+ Write-ToLog "-> Modifications for $AppID before install are being applied..." "Yellow"
+ & "$ModsPreInstall"
+ }
+
+ #Install App
+ Write-ToLog "-> Installing $AppID..." "Yellow"
+ $WingetArgs = "install --id $AppID -e --accept-package-agreements --accept-source-agreements -s winget -h $AppArgs" -split " "
+ Write-ToLog "-> Running: `"$Winget`" $WingetArgs"
+ & "$Winget" $WingetArgs | Where-Object { $_ -notlike " *" } | Tee-Object -file $LogFile -Append
+
+ if ($ModsInstall) {
+ Write-ToLog "-> Modifications for $AppID during install are being applied..." "Yellow"
+ & "$ModsInstall"
+ }
+
+ #Check if install is ok
+ $IsInstalled = Confirm-Installation $AppID
+ if ($IsInstalled) {
+ Write-ToLog "-> $AppID successfully installed." "Green"
+
+ if ($ModsInstalledOnce) {
+ Write-ToLog "-> Modifications for $AppID after install (one time) are being applied..." "Yellow"
+ & "$ModsInstalledOnce"
+ }
+ elseif ($ModsInstalled) {
+ Write-ToLog "-> Modifications for $AppID after install are being applied..." "Yellow"
+ & "$ModsInstalled"
+ }
+
+ #Add mods if deployed from Winget-Install
+ if ((Test-Path "$PSScriptRoot\mods\$AppID-preinstall.ps1") -or (Test-Path "$PSScriptRoot\mods\$AppID-upgrade.ps1") -or (Test-Path "$PSScriptRoot\mods\$AppID-install.ps1") -or (Test-Path "$PSScriptRoot\mods\$AppID-installed.ps1")) {
+ Add-WAUMods $AppID
+ }
+
+ #Add to WAU White List if set
+ if ($WAUWhiteList) {
+ Add-WAUWhiteList $AppID
+ }
+ }
+ else {
+ Write-ToLog "-> $AppID installation failed!" "Red"
+ }
+ }
+ else {
+ Write-ToLog "-> $AppID is already installed." "Cyan"
+ }
+}
+
+#Uninstall function
+function Uninstall-App ($AppID, $AppArgs) {
+ $IsInstalled = Confirm-Installation $AppID
+ if ($IsInstalled) {
+ #Check if mods exist (or already exist) for preuninstall/uninstall/uninstalled
+ $ModsPreUninstall, $ModsUninstall, $ModsUninstalled = Test-ModsUninstall $AppID
+
+ #If PreUninstall script exist
+ if ($ModsPreUninstall) {
+ Write-ToLog "-> Modifications for $AppID before uninstall are being applied..." "Yellow"
+ & "$ModsPreUninstall"
+ }
+
+ #Uninstall App
+ Write-ToLog "-> Uninstalling $AppID..." "Yellow"
+ $WingetArgs = "uninstall --id $AppID -e --accept-source-agreements -h" -split " "
+ Write-ToLog "-> Running: `"$Winget`" $WingetArgs"
+ & "$Winget" $WingetArgs | Where-Object { $_ -notlike " *" } | Tee-Object -file $LogFile -Append
+
+ if ($ModsUninstall) {
+ Write-ToLog "-> Modifications for $AppID during uninstall are being applied..." "Yellow"
+ & "$ModsUninstall"
+ }
+
+ #Check if uninstall is ok
+ $IsInstalled = Confirm-Installation $AppID
+ if (!($IsInstalled)) {
+ Write-ToLog "-> $AppID successfully uninstalled." "Green"
+ if ($ModsUninstalled) {
+ Write-ToLog "-> Modifications for $AppID after uninstall are being applied..." "Yellow"
+ & "$ModsUninstalled"
+ }
+
+ #Remove mods if deployed from Winget-Install
+ if ((Test-Path "$PSScriptRoot\mods\$AppID-preinstall.ps1") -or (Test-Path "$PSScriptRoot\mods\$AppID-upgrade.ps1") -or (Test-Path "$PSScriptRoot\mods\$AppID-install.ps1") -or (Test-Path "$PSScriptRoot\mods\$AppID-installed.ps1")) {
+ Remove-WAUMods $AppID
+ }
+
+ #Remove from WAU White List if set
+ if ($WAUWhiteList) {
+ Remove-WAUWhiteList $AppID
+ }
+ }
+ else {
+ Write-ToLog "-> $AppID uninstall failed!" "Red"
+ }
+ }
+ else {
+ Write-ToLog "-> $AppID is not installed." "Cyan"
+ }
+}
+
+#Function to Add app to WAU white list
+function Add-WAUWhiteList ($AppID) {
+ #Check if WAU default intall path exists
+ $WhiteList = "$WAUInstallLocation\included_apps.txt"
+ if (Test-Path $WhiteList) {
+ Write-ToLog "-> Add $AppID to WAU included_apps.txt"
+ #Add App to "included_apps.txt"
+ Add-Content -path $WhiteList -Value "`n$AppID" -Force
+ #Remove duplicate and blank lines
+ $file = Get-Content $WhiteList | Select-Object -Unique | Where-Object { $_.trim() -ne "" } | Sort-Object
+ $file | Out-File $WhiteList
+ }
+}
+
+#Function to Remove app from WAU white list
+function Remove-WAUWhiteList ($AppID) {
+ #Check if WAU default intall path exists
+ $WhiteList = "$WAUInstallLocation\included_apps.txt"
+ if (Test-Path $WhiteList) {
+ Write-ToLog "-> Remove $AppID from WAU included_apps.txt"
+ #Remove app from list
+ $file = Get-Content $WhiteList | Where-Object { $_ -ne "$AppID" }
+ $file | Out-File $WhiteList
+ }
+}
+
+#Function to Add Mods to WAU "mods"
+function Add-WAUMods ($AppID) {
+ #Check if WAU default install path exists
+ $Mods = "$WAUInstallLocation\mods"
+ if (Test-Path $Mods) {
+ #Add mods
+ Write-ToLog "-> Add modifications for $AppID to WAU 'mods'"
+ Copy-Item "$PSScriptRoot\mods\$AppID-*" -Destination "$Mods" -Exclude "*installed-once*", "*uninstall*" -Force
+ }
+}
+
+#Function to Remove Mods from WAU "mods"
+function Remove-WAUMods ($AppID) {
+ #Check if WAU default install path exists
+ $Mods = "$WAUInstallLocation\mods"
+ if (Test-Path "$Mods\$AppID*") {
+ Write-ToLog "-> Remove $AppID modifications from WAU 'mods'"
+ #Remove mods
+ Remove-Item -Path "$Mods\$AppID-*" -Exclude "*uninstall*" -Force
+ }
+}
+
+
+<# MAIN #>
+
+#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 -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command $($MyInvocation.line)"
+ Exit $lastexitcode
+ }
+}
+
+#Config console output encoding
+$null = cmd /c '' #Tip for ISE
+[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
+$Script:ProgressPreference = 'SilentlyContinue'
+
+#Check if current process is elevated (System or admin user)
+$CurrentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
+$Script:IsElevated = $CurrentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
+
+#Get WAU Installed location
+$WAURegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\"
+$Script:WAUInstallLocation = Get-ItemProperty $WAURegKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty InstallLocation
+
+#LogPath initialisation
+if (!($LogPath)) {
+ #If LogPath is not set, get WAU log path
+ if ($WAUInstallLocation) {
+ $LogPath = "$WAUInstallLocation\Logs"
+ }
+ else {
+ #Else, set a default one
+ $LogPath = "$env:ProgramData\Winget-AutoUpdate\Logs"
+ }
+}
+
+#Logs initialisation
+if (!(Test-Path $LogPath)) {
+ New-Item -ItemType Directory -Force -Path $LogPath | Out-Null
+}
+
+#Log file
+if ($IsElevated) {
+ $Script:LogFile = "$LogPath\install.log"
+}
+else {
+ $Script:LogFile = "$LogPath\install_$env:UserName.log"
+}
+
+#Header (not logged)
+Write-Host "`n "
+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
+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
+Write-Host "`t 888P Y888 d88P 888 Y8888888P`n" -ForegroundColor Magenta
+Write-Host "`t Winget-AutoUpdate`n" -ForegroundColor Cyan
+Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -ForegroundColor Magenta
+Write-Host "`t________________________________________________________`n`n"
+
+#Log Header
+if ($Uninstall) {
+ Write-ToLog -LogMsg "NEW UNINSTALL REQUEST" -LogColor "Magenta" -IsHeader
+}
+else {
+ Write-ToLog -LogMsg "NEW INSTALL REQUEST" -LogColor "Magenta" -IsHeader
+}
+
+#Get Winget command
+$Script:Winget = Get-WingetCmd
+
+if ($IsElevated -eq $True) {
+ Write-ToLog "Running with admin rights.`n "
+ #Check/install prerequisites
+ Install-Prerequisites
+ #Install/Update Winget
+ $null = Update-Winget
+ #Reload Winget command
+ $Script:Winget = Get-WingetCmd
+ #Run Scope Machine funtion
+ Add-ScopeMachine
+}
+else {
+ Write-ToLog "Running without admin rights.`n "
+}
+
+if ($Winget) {
+ #Run install or uninstall for all apps
+ foreach ($App_Full in $AppIDs) {
+ #Split AppID and Custom arguments
+ $AppID, $AppArgs = ($App_Full.Trim().Split(" ", 2))
+
+ #Log current App
+ Write-ToLog "Start $AppID processing..." "Blue"
+
+ #Install or Uninstall command
+ if ($Uninstall) {
+ Uninstall-App $AppID $AppArgs
+ }
+ else {
+ #Check if app exists on Winget Repo
+ $Exists = Confirm-Exist $AppID
+ if ($Exists) {
+ #Install
+ Install-App $AppID $AppArgs
+ }
+ }
+
+ #Log current App
+ Write-ToLog "$AppID processing finished!`n" "Blue"
+ Start-Sleep 1
+ }
+}
+
+Write-ToLog "### END REQUEST ###`n" "Magenta"
+Start-Sleep 3
\ No newline at end of file
diff --git a/Winget-AutoUpdate/functions/Confirm-Installation.ps1 b/Winget-AutoUpdate/functions/Confirm-Installation.ps1
index 8ee0005..a343113 100644
--- a/Winget-AutoUpdate/functions/Confirm-Installation.ps1
+++ b/Winget-AutoUpdate/functions/Confirm-Installation.ps1
@@ -1,7 +1,7 @@
-Function Confirm-Installation ($AppName, $AppVer){
+Function Confirm-Installation ($AppName, $AppVer) {
#Set json export file
- $JsonFile = "$WorkingDir\InstalledApps.json"
+ $JsonFile = "$env:TEMP\InstalledApps.json"
#Get installed apps and version in json file
& $Winget export -s winget -o $JsonFile --include-versions | Out-Null
@@ -16,12 +16,12 @@ Function Confirm-Installation ($AppName, $AppVer){
Remove-Item $JsonFile -Force
# Search for specific app and version
- $Apps = $Packages | Where-Object { $_.PackageIdentifier -eq $AppName -and $_.Version -like "$AppVer*"}
+ $Apps = $Packages | Where-Object { $_.PackageIdentifier -eq $AppName -and $_.Version -like "$AppVer*" }
- if ($Apps){
+ if ($Apps) {
return $true
}
- else{
+ else {
return $false
}
}
\ No newline at end of file
diff --git a/install.bat b/install.bat
deleted file mode 100644
index b82a95b..0000000
--- a/install.bat
+++ /dev/null
@@ -1,15 +0,0 @@
-@echo off
-
-::::::::::::::::::::::::::::
-:: Put WAU Arguments here ::
-::::::::::::::::::::::::::::
-
-SET arguments=-UpdatesAtLogon -UpdatesInterval Weekly -InstallUserContext -StartMenuShortcut -DesktopShortcut
-
-
-::::::::::::::::::::::::::::
-:: Run Powershell Script ::
-::::::::::::::::::::::::::::
-
-SET PowershellCmd=Start-Process powershell.exe -Verb RunAs -Argument '-noprofile -executionpolicy bypass -file "%~dp0Winget-AutoUpdate-Install.ps1" %arguments%
-powershell -Command "& {Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; %PowershellCmd%'}"
diff --git a/uninstall.bat b/uninstall.bat
deleted file mode 100644
index 9a33c87..0000000
--- a/uninstall.bat
+++ /dev/null
@@ -1,15 +0,0 @@
-@echo off
-
-::::::::::::::::::::::::::::
-:: Put WAU Arguments here ::
-::::::::::::::::::::::::::::
-
-SET arguments=-Uninstall
-
-
-::::::::::::::::::::::::::::
-:: Run Powershell Script ::
-::::::::::::::::::::::::::::
-
-SET PowershellCmd=Start-Process powershell.exe -Verb RunAs -Argument '-noprofile -executionpolicy bypass -file "%~dp0Winget-AutoUpdate-Install.ps1" %arguments%
-powershell -Command "& {Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; %PowershellCmd%'}"