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