From 92e64a145c083fd075089d7ad205218f61b76bf8 Mon Sep 17 00:00:00 2001 From: Andreas Brett Date: Tue, 24 Oct 2023 18:30:56 +0200 Subject: [PATCH] Stop running Get-Command Under User Get-Command winget.exe not always returns an installed winget --- Winget-AutoUpdate/functions/Get-WingetCmd.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 b/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 index e0be4e4..22d2d70 100644 --- a/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 @@ -18,9 +18,8 @@ Function Get-WingetCmd { } }else{ #Get Winget Location in User context - $WingetCmd = Get-Command winget.exe -ErrorAction SilentlyContinue - if ($WingetCmd) { - $Script:Winget = $WingetCmd.Source + if (Test-Path "$env:LocalAppData\Microsoft\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\winget.exe") { + $Script:Winget = "$env:LocalAppData\Microsoft\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\winget.exe" } }