Skip to content

Commit c112998

Browse files
Fixed uninstalled python versions being listed
1 parent e61f0e6 commit c112998

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Source/EnablePython.psd1

3.4 KB
Binary file not shown.

Source/EnablePython.psm1

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,13 @@ function Get-Python {
128128
process {
129129
$versions = New-Object System.Collections.Generic.List[PSObject]
130130

131-
$nativeKeys = Get-ChildItem -Path Registry::HKLM\Software\Python\PythonCore\ -ErrorAction "SilentlyContinue"
132-
foreach ($key in $nativeKeys) {
133-
$versions.Add((createCPythonVersion $key))
134-
}
131+
[Microsoft.Win32.RegistryKey[]]$regKeys = Get-ChildItem -Path Registry::HKLM\Software\Python\PythonCore\ -ErrorAction "SilentlyContinue"
132+
[Microsoft.Win32.RegistryKey[]]$regKeys = $regKeys + (Get-ChildItem -Path Registry::HKLM\SOFTWARE\Wow6432Node\Python\PythonCore\ -ErrorAction "SilentlyContinue")
135133

136-
$wowKeys = Get-ChildItem -Path Registry::HKLM\SOFTWARE\Wow6432Node\Python\PythonCore\ -ErrorAction "SilentlyContinue"
137-
foreach ($key in $wowKeys) {
138-
$versions.Add((createCPythonVersion $key))
134+
foreach ($key in $regKeys) {
135+
if (Test-Path ("Registry::" + (Join-Path $key.Name "\InstallPath"))) {
136+
$versions.Add((createCPythonVersion $key))
137+
}
139138
}
140139

141140
($versions |

0 commit comments

Comments
 (0)