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] 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 = @" + + + + +