This repository was archived by the owner on Dec 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed
Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ $AppToDetect = "Notepad++.Notepad++"
77Function Get-WingetCmd {
88
99 # Get WinGet Path (if admin context)
10- $ResolveWingetPath = Resolve-Path " C:\Program Files\ WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
10+ $ResolveWingetPath = Resolve-Path " $ env: ProgramFiles \ WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe" | Sort-Object { [ version ]( $_ .Path -replace ' ^[^\d]+_((\d+\.)*\d+)_.* ' , ' $1 ' ) }
1111 if ($ResolveWingetPath ) {
1212 # If multiple version, pick last one
1313 $WingetPath = $ResolveWingetPath [-1 ].Path
@@ -18,11 +18,7 @@ Function Get-WingetCmd {
1818 if ($WingetCmd ) {
1919 $Script :Winget = $WingetCmd.Source
2020 }
21- # Get Winget Location in System context (WinGet < 1.17)
22- elseif (Test-Path " $WingetPath \AppInstallerCLI.exe" ) {
23- $Script :Winget = " $WingetPath \AppInstallerCLI.exe"
24- }
25- # Get Winget Location in System context (WinGet > 1.17)
21+ # Get Winget Location in System context
2622 elseif (Test-Path " $WingetPath \winget.exe" ) {
2723 $Script :Winget = " $WingetPath \winget.exe"
2824 }
Original file line number Diff line number Diff line change @@ -99,9 +99,9 @@ function Write-Log ($LogMsg, $LogColor = "White") {
9999# Get WinGet Location Function
100100function Get-WingetCmd {
101101 # Get WinGet Path (if admin context)
102- $ResolveWingetPath = Resolve-Path " $env: ProgramFiles \WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
102+ $ResolveWingetPath = Resolve-Path " $env: ProgramFiles \WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe" | Sort-Object { [ version ]( $_ .Path -replace ' ^[^\d]+_((\d+\.)*\d+)_.* ' , ' $1 ' ) }
103103 if ($ResolveWingetPath ) {
104- # If multiple versions (when pre-release versions are installed) , pick last one
104+ # If multiple versions, pick last one
105105 $WingetPath = $ResolveWingetPath [-1 ].Path
106106 }
107107 # Get WinGet Location in User context
@@ -114,7 +114,7 @@ function Get-WingetCmd {
114114 $Script :Winget = " $WingetPath \winget.exe"
115115 }
116116 else {
117- Write-Log " Winget not installed !" " Red"
117+ Write-Log " Winget not installed or detected !" " Red"
118118 break
119119 }
120120 Write-Log " Using following Winget Cmd: $winget `n "
You can’t perform that action at this time.
0 commit comments