From edc3051101d3b40cb62f5f1832153991087b8d13 Mon Sep 17 00:00:00 2001 From: romanitho <96626929+Romanitho@users.noreply.github.com> Date: Thu, 7 Dec 2023 01:09:22 +0100 Subject: [PATCH] Use admin right for app install by default --- Gui.ps1 | 11 +++++++++-- .../functions/Invoke-PostUpdateActions.ps1 | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Gui.ps1 b/Gui.ps1 index 9b4e9f8..e6bd5d1 100644 --- a/Gui.ps1 +++ b/Gui.ps1 @@ -195,7 +195,14 @@ function Start-Installations { 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 + + #Try with admin rights. + try { + Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command `"$WAUInstallPath\Winget-Install.ps1 -AppIDs $AppToInstall`"" -Wait -Verb RunAs + } + catch { + Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command `"$WAUInstallPath\Winget-Install.ps1 -AppIDs $AppToInstall`"" -Wait + } } @@ -775,7 +782,7 @@ Start-PopUp "Starting..." Get-WAUConfiguratorLatestVersion #Check if Winget is installed, and install if not -Update-WinGet +$null = Update-WinGet #Get WinGet cmd $Script:Winget = Get-WingetCmd diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index f5b82b7..e451280 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -18,7 +18,7 @@ function Invoke-PostUpdateActions { } #Update Winget if not up to date - Update-WinGet + $null = Update-WinGet #Create WAU Regkey if not present $regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"