From 9f165a8b3daa7b5733cf51e573d260d143800ab3 Mon Sep 17 00:00:00 2001
From: romanitho <96626929+Romanitho@users.noreply.github.com>
Date: Wed, 6 Dec 2023 00:52:41 +0100
Subject: [PATCH 1/4] Gui
---
Gui.ps1 | 784 +++++++++++++++++++++++++++
WAU Configurator.lnk | Bin 0 -> 2642 bytes
Winget-AutoUpdate/Winget-Install.ps1 | 0
install.bat | 15 -
uninstall.bat | 15 -
5 files changed, 784 insertions(+), 30 deletions(-)
create mode 100644 Gui.ps1
create mode 100644 WAU Configurator.lnk
create mode 100644 Winget-AutoUpdate/Winget-Install.ps1
delete mode 100644 install.bat
delete mode 100644 uninstall.bat
diff --git a/Gui.ps1 b/Gui.ps1
new file mode 100644
index 0000000..f9e3efd
--- /dev/null
+++ b/Gui.ps1
@@ -0,0 +1,784 @@
+<#
+.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
+ }
+
+ ## WAU PART ##
+
+ #Download and install Winget-AutoUpdate if box is checked
+ if ($InstallWAU) {
+
+ Start-PopUp "Installing WAU..."
+
+ #Set WAU subfolder
+ $WAUInstallFolder = "$PSScriptRoot\WAU"
+
+ #Configure parameters
+ $WAUParameters = "-Silent "
+ if ($WAUDoNotUpdate) {
+ $WAUParameters += "-DoNotUpdate "
+ }
+ if ($WAUDisableAU) {
+ $WAUParameters += "-DisableWAUAutoUpdate "
+ }
+ if ($WAUNotificationLevel) {
+ $WAUParameters += "-NotificationLevel $WAUNotificationLevel "
+ }
+ if ($WAUFreqUpd) {
+ $WAUParameters += "-UpdatesInterval $WAUFreqUpd "
+ }
+ if ($WAUAtUserLogon) {
+ $WAUParameters += "-UpdatesAtLogon "
+ }
+ if ($WAUonMetered) {
+ $WAUParameters += "-RunOnMetered "
+ }
+ if ($WAUUseWhiteList) {
+ $WAUParameters += "-UseWhiteList "
+ if ($WAUListPath) {
+ Copy-Item $WAUListPath -Destination "$WAUInstallFolder\included_apps.txt" -Force -ErrorAction SilentlyContinue
+ }
+ }
+ else {
+ if ($WAUListPath) {
+ Copy-Item $WAUListPath -Destination "$WAUInstallFolder\excluded_apps.txt" -Force -ErrorAction SilentlyContinue
+ }
+ }
+ if ($WAUDesktopShortcut) {
+ $WAUParameters += "-DesktopShortcut "
+ }
+ if ($WAUStartMenuShortcut) {
+ $WAUParameters += "-StartMenuShortcut "
+ }
+ if ($WAUInstallUserContext) {
+ $WAUParameters += "-InstallUserContext "
+ }
+
+ #Install Winget-Autoupdate
+ Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command `"$WAUInstallFolder\Winget-AutoUpdate-Install.ps1 $WAUParameters`"" -Wait -Verb RunAs
+ }
+
+ ## 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 0000000000000000000000000000000000000000..b9e20e7f84d4dec142ba78a2549bf2297f17b26c
GIT binary patch
literal 2642
zcmds3U1-x+6#peUYUjsNj8a8sR*0n2{FkK7+C~JmSzBDGo#_^pe?e`c$!wa?)TZ@g
zOwb2M_aJlNgDb5#tD{v^qz_Y3d=#WOCaxfe6#OWw^KB1;`<JmJ@epVTH@}%OZSM?bD4zQ;TolR+~uh%oYoR(Y8=LmBbnpVkVwm
z9cX&w5RS$(PIb;SbyclqkJ(H?MA3#2;z%J$>OyQWq&}w9KzFhu94qqx>$2oNR&qr)
z-B)-DT`jgEfNsj`Ko~KUf!9&YUE1D(rgNo+y^ZlyxIGXFx3;3m&~UCa61<=^oSq?a
zb2Stk^dj5xM&&^m?bIBh)>i(&Bs64nt_?a0E$DP>F2I+i=d9B6TV6d!zr2Y~O3=V-
zuu>*HVe$gOKabmx5Yv-lx)$yVgSyg@7j9Fq$1l-2HIpb~|38KspY~TEVOX3rEY@gw
z7XkQ~5Fsqd+?F|=MPMh_MFcVV;Df|*3umxIG8Ldt=4_HM6=Gcipy%4Xj{a%T^Wf|l
z>#t;0e~m2YMg;X~eO^WX!aQMPrFC=O#`;Ne=VWEt7zc9c9C8~ek*0JBCkYwSc~1HX_TI1R!gv-@Coc$er@FaIBV6;h~!qWQ0njn
z>iLtZ*7)T}rAY=p0Q&5l?-3+hv$;<-Twnaq+}tqi*Uq2)>e#UGwi1}RzD=BEl(p<|
zw}e6-r?=eWa+arwFX2DDcV9TZn?{I~=I@-1IYip9}d-9HyV{Kx5!<*Ok#~9IhSscVzy_
z?($)<0EgH6ZBR*+pL`C3EviF}1rDk{`CL@b6p_+eAc<@(C%-=EL_
zY5B3(ttjd0#SlYQ5&|^GP4E&tYUSZuRE`Q%5m%A!CEbZi&O)msSD-@Cd23Ja_@KPfAIbqS;v>TJPZh8rbB_N#IOZNve{zI4
zNA|LiM^lDG!0=DFYbiXz4jN_8-o~yQW$$exT`tWdD3QkhChq$QV)UtRTO6x@zFlRC#
Date: Wed, 6 Dec 2023 01:05:18 +0100
Subject: [PATCH 2/4] fix zip
---
Gui.ps1 | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/Gui.ps1 b/Gui.ps1
index f9e3efd..c89a695 100644
--- a/Gui.ps1
+++ b/Gui.ps1
@@ -300,7 +300,7 @@ function Get-WAUConfiguratorLatestVersion {
mc:Ignorable="d"
Title="WAU Configurator {0} - Update available" ResizeMode="NoResize" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen" Topmost="True">
-
+
@@ -336,17 +336,20 @@ function Get-WAUConfiguratorLatestVersion {
$DownloadButton.add_click(
{
$WAUConfiguratorSaveFile = New-Object System.Windows.Forms.SaveFileDialog
- $WAUConfiguratorSaveFile.Filter = "Exe file (*.exe)|*.exe"
- $WAUConfiguratorSaveFile.FileName = "WAUConfigurator_$WAUConfiguratorLatestVersion.exe"
+ $WAUConfiguratorSaveFile.Filter = "Zip file (*.zip)|*.zip"
+ $WAUConfiguratorSaveFile.FileName = "WAU_$WAUConfiguratorLatestVersion.zip"
$response = $WAUConfiguratorSaveFile.ShowDialog() # $response can return OK or Cancel
if ( $response -eq 'OK' ) {
- Start-PopUp "Downloading WAUConfigurator $WAUConfiguratorLatestVersion..."
+ Start-PopUp "Downloading WAU Configurator $WAUConfiguratorLatestVersion..."
$WAUConfiguratorDlLink = "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$WAUConfiguratorLatestVersion/WAU.zip"
Invoke-WebRequest -Uri $WAUConfiguratorDlLink -OutFile $WAUConfiguratorSaveFile.FileName -UseBasicParsing
$UpdateWindow.DialogResult = [System.Windows.Forms.DialogResult]::OK
$UpdateWindow.Close()
Start-Sleep 3
+ #Open folder
+ Start-Process (Split-Path -parent $WAUConfiguratorSaveFile.FileName)
+
Close-PopUp
Exit 0
}
From c5309ff72f72cf1a41bef878cac28f03c376cf4c Mon Sep 17 00:00:00 2001
From: romanitho <96626929+Romanitho@users.noreply.github.com>
Date: Wed, 6 Dec 2023 01:42:38 +0100
Subject: [PATCH 3/4] add Winget-Install script
---
Gui.ps1 | 166 ++++---
Winget-AutoUpdate/Winget-Install.ps1 | 407 ++++++++++++++++++
.../functions/Confirm-Installation.ps1 | 10 +-
3 files changed, 494 insertions(+), 89 deletions(-)
diff --git a/Gui.ps1 b/Gui.ps1
index c89a695..9b4e9f8 100644
--- a/Gui.ps1
+++ b/Gui.ps1
@@ -136,16 +136,6 @@ function Get-WingetInstalledApps {
function Start-Installations {
- ## WINGET-INSTALL PART ##
-
- #Run Winget-Install script if box is checked
- if ($AppToInstall) {
-
- Start-PopUp "Installing applications..."
-
- Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command `"$PSScriptRoot\Winget-AutoUpdate\Winget-Install.ps1 -AppIDs $AppToInstall`"" -Wait #-Verb RunAs -> Removing admin rights for user context apps
- }
-
## WAU PART ##
#Download and install Winget-AutoUpdate if box is checked
@@ -153,9 +143,6 @@ function Start-Installations {
Start-PopUp "Installing WAU..."
- #Set WAU subfolder
- $WAUInstallFolder = "$PSScriptRoot\WAU"
-
#Configure parameters
$WAUParameters = "-Silent "
if ($WAUDoNotUpdate) {
@@ -179,12 +166,12 @@ function Start-Installations {
if ($WAUUseWhiteList) {
$WAUParameters += "-UseWhiteList "
if ($WAUListPath) {
- Copy-Item $WAUListPath -Destination "$WAUInstallFolder\included_apps.txt" -Force -ErrorAction SilentlyContinue
+ Copy-Item $WAUListPath -Destination "$PSScriptRoot\included_apps.txt" -Force -ErrorAction SilentlyContinue
}
}
else {
if ($WAUListPath) {
- Copy-Item $WAUListPath -Destination "$WAUInstallFolder\excluded_apps.txt" -Force -ErrorAction SilentlyContinue
+ Copy-Item $WAUListPath -Destination "$PSScriptRoot\excluded_apps.txt" -Force -ErrorAction SilentlyContinue
}
}
if ($WAUDesktopShortcut) {
@@ -198,9 +185,20 @@ function Start-Installations {
}
#Install Winget-Autoupdate
- Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command `"$WAUInstallFolder\Winget-AutoUpdate-Install.ps1 $WAUParameters`"" -Wait -Verb RunAs
+ Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command `"$PSScriptRoot\Winget-AutoUpdate-Install.ps1 $WAUParameters`"" -Wait -Verb RunAs
}
+
+ ## WINGET-INSTALL PART ##
+
+ #Run Winget-Install script if box is checked
+ if ($AppToInstall) {
+ Start-PopUp "Installing applications..."
+ $WAUInstallPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
+ Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command `"$WAUInstallPath\Winget-Install.ps1 -AppIDs $AppToInstall`"" -Wait #-Verb RunAs -> Removing admin rights for user context apps
+ }
+
+
## ADMIN PART ##
if ($CMTrace) {
@@ -505,6 +503,74 @@ function Start-InstallGUI {
### FORM ACTIONS ###
+ ##
+ # "Configure WAU" Tab
+ ##
+ $WAUCheckBox.add_click(
+ {
+ if ($WAUCheckBox.IsChecked -eq $true) {
+ $WAUConfGroupBox.IsEnabled = $true
+ $WAUFreqGroupBox.IsEnabled = $true
+ $WAUWhiteBlackGroupBox.IsEnabled = $true
+ $WAUShortcutsGroupBox.IsEnabled = $true
+ }
+ elseif ($WAUCheckBox.IsChecked -eq $false) {
+ $WAUConfGroupBox.IsEnabled = $false
+ $WAUFreqGroupBox.IsEnabled = $false
+ $WAUWhiteBlackGroupBox.IsEnabled = $false
+ $WAUShortcutsGroupBox.IsEnabled = $false
+ }
+ }
+ )
+
+ $WAUMoreInfoLabel.Add_PreviewMouseDown(
+ {
+ [System.Diagnostics.Process]::Start("https://github.com/Romanitho/Winget-AutoUpdate")
+ }
+ )
+
+ $BlackRadioBut.add_click(
+ {
+ $WAULoadListButton.IsEnabled = $true
+ }
+ )
+
+ $WhiteRadioBut.add_click(
+ {
+ $WAULoadListButton.IsEnabled = $true
+ }
+ )
+
+ $DefaultRadioBut.add_click(
+ {
+ $WAULoadListButton.IsEnabled = $false
+ $WAUListFileTextBox.Clear()
+ }
+ )
+
+ $WAULoadListButton.add_click(
+ {
+ $response = $WAUListOpenFile.ShowDialog() # $response can return OK or Cancel
+ if ( $response -eq 'OK' ) {
+ $WAUListFileTextBox.Text = $WAUListOpenFile.FileName
+ }
+ }
+ )
+
+ $UninstallWAUButton.add_click(
+ {
+ #Uninstall WAU from registry command
+ $Arguments = Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "UninstallString"
+ Start-Process "cmd.exe" -ArgumentList "/c $Arguments" -Wait -Verb RunAs
+ $WAUInstallStatus = Get-WAUInstallStatus
+ $WAUStatusLabel.Text = $WAUInstallStatus[0]
+ $WAUStatusLabel.Foreground = $WAUInstallStatus[1]
+ $AppsTabPage.IsEnabled = $WAUInstallStatus[2]
+ $UninstallWAUButton.IsEnabled = $WAUInstallStatus[2]
+ $AppListBox.Items.Clear()
+ }
+ )
+
##
# "Select Apps" Tab
##
@@ -600,74 +666,6 @@ function Start-InstallGUI {
}
)
- ##
- # "Configure WAU" Tab
- ##
- $WAUCheckBox.add_click(
- {
- if ($WAUCheckBox.IsChecked -eq $true) {
- $WAUConfGroupBox.IsEnabled = $true
- $WAUFreqGroupBox.IsEnabled = $true
- $WAUWhiteBlackGroupBox.IsEnabled = $true
- $WAUShortcutsGroupBox.IsEnabled = $true
- }
- elseif ($WAUCheckBox.IsChecked -eq $false) {
- $WAUConfGroupBox.IsEnabled = $false
- $WAUFreqGroupBox.IsEnabled = $false
- $WAUWhiteBlackGroupBox.IsEnabled = $false
- $WAUShortcutsGroupBox.IsEnabled = $false
- }
- }
- )
-
- $WAUMoreInfoLabel.Add_PreviewMouseDown(
- {
- [System.Diagnostics.Process]::Start("https://github.com/Romanitho/Winget-AutoUpdate")
- }
- )
-
- $BlackRadioBut.add_click(
- {
- $WAULoadListButton.IsEnabled = $true
- }
- )
-
- $WhiteRadioBut.add_click(
- {
- $WAULoadListButton.IsEnabled = $true
- }
- )
-
- $DefaultRadioBut.add_click(
- {
- $WAULoadListButton.IsEnabled = $false
- $WAUListFileTextBox.Clear()
- }
- )
-
- $WAULoadListButton.add_click(
- {
- $response = $WAUListOpenFile.ShowDialog() # $response can return OK or Cancel
- if ( $response -eq 'OK' ) {
- $WAUListFileTextBox.Text = $WAUListOpenFile.FileName
- }
- }
- )
-
- $UninstallWAUButton.add_click(
- {
- #Uninstall WAU from registry command
- $Arguments = Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "UninstallString"
- Start-Process "cmd.exe" -ArgumentList "/c $Arguments" -Wait -Verb RunAs
- $WAUInstallStatus = Get-WAUInstallStatus
- $WAUStatusLabel.Text = $WAUInstallStatus[0]
- $WAUStatusLabel.Foreground = $WAUInstallStatus[1]
- $AppsTabPage.IsEnabled = $WAUInstallStatus[2]
- $UninstallWAUButton.IsEnabled = $WAUInstallStatus[2]
- $AppListBox.Items.Clear()
- }
- )
-
##
# "Admin Tool" Tab by hitting F9 Key
##
diff --git a/Winget-AutoUpdate/Winget-Install.ps1 b/Winget-AutoUpdate/Winget-Install.ps1
index e69de29..c93fe5d 100644
--- a/Winget-AutoUpdate/Winget-Install.ps1
+++ 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
+ 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
From 952feed01af76adec2a685f29781d2bb05761813 Mon Sep 17 00:00:00 2001
From: romanitho <96626929+Romanitho@users.noreply.github.com>
Date: Wed, 6 Dec 2023 01:58:49 +0100
Subject: [PATCH 4/4] Gui integration in release
---
.github/workflows/WAU-AutoCreatePreVersion.yml | 4 ++--
.github/workflows/WAU-CreateNewVersion.yml | 4 ++--
Winget-AutoUpdate/Winget-Install.ps1 | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
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/Winget-AutoUpdate/Winget-Install.ps1 b/Winget-AutoUpdate/Winget-Install.ps1
index c93fe5d..be669cf 100644
--- a/Winget-AutoUpdate/Winget-Install.ps1
+++ b/Winget-AutoUpdate/Winget-Install.ps1
@@ -365,7 +365,7 @@ if ($IsElevated -eq $True) {
#Check/install prerequisites
Install-Prerequisites
#Install/Update Winget
- Update-Winget
+ $null = Update-Winget
#Reload Winget command
$Script:Winget = Get-WingetCmd
#Run Scope Machine funtion