Skip to content

Commit 8094780

Browse files
EscVectormross22
authored andcommitted
Added Null Directory Check (#44)
FindLatestPythonExecutableInRegistry - Added Null Directory Check to ignore registry key that exists, but is null.
1 parent fabed1e commit 8094780

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

scripts/install/install.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,16 @@ function FindLatestPythonExecutableInRegistry {
101101
$PythonCoreRegistryLocation = "${RootRegistryLocation}:\Software\Python\PythonCore"
102102
if (Test-Path $PythonCoreRegistryLocation) {
103103
LogOutput "Python found in registry: $PythonCoreRegistryLocation"
104-
105104
$PythonInstallations = (Get-ChildItem -recurse $PythonCoreRegistryLocation) | Sort-Object -Descending
106-
ForEach ($Installation in $PythonInstallations) {
107-
# we are sorting by descending so this will grab the greatest installed version of python
108-
If ($installation.Name.EndsWith("\InstallPath")) {
109-
$PythonInstallLocation = (Get-ItemProperty -LiteralPath $Installation.PSPath).'(default)'
110-
return Join-Path $PythonInstallLocation "python.exe"
111-
}
112-
}
105+
if ($PythonInstallations) {
106+
ForEach ($Installation in $PythonInstallations) {
107+
# we are sorting by descending so this will grab the greatest installed version of python
108+
If ($installation.Name.EndsWith("\InstallPath")) {
109+
$PythonInstallLocation = (Get-ItemProperty -LiteralPath $Installation.PSPath).'(default)'
110+
return Join-Path $PythonInstallLocation "python.exe"
111+
}
112+
}
113+
}
113114
}
114115

115116
return $PythonExecutable

0 commit comments

Comments
 (0)