From 4341da7383492ae4de6421e7eba98eb8355984db Mon Sep 17 00:00:00 2001 From: Ted Date: Tue, 20 Feb 2018 12:59:21 -0500 Subject: [PATCH] Added Null Directory Check FindLatestPythonExecutableInRegistry - Added Null Directory Check to ignore registry key that exists, but is null. --- scripts/install/install.ps1 | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/install/install.ps1 b/scripts/install/install.ps1 index ddd554563..948dcf384 100644 --- a/scripts/install/install.ps1 +++ b/scripts/install/install.ps1 @@ -101,15 +101,16 @@ function FindLatestPythonExecutableInRegistry { $PythonCoreRegistryLocation = "${RootRegistryLocation}:\Software\Python\PythonCore" if (Test-Path $PythonCoreRegistryLocation) { LogOutput "Python found in registry: $PythonCoreRegistryLocation" - $PythonInstallations = (Get-ChildItem -recurse $PythonCoreRegistryLocation) | Sort-Object -Descending - ForEach ($Installation in $PythonInstallations) { - # we are sorting by descending so this will grab the greatest installed version of python - If ($installation.Name.EndsWith("\InstallPath")) { - $PythonInstallLocation = (Get-ItemProperty -LiteralPath $Installation.PSPath).'(default)' - return Join-Path $PythonInstallLocation "python.exe" - } - } + if ($PythonInstallations) { + ForEach ($Installation in $PythonInstallations) { + # we are sorting by descending so this will grab the greatest installed version of python + If ($installation.Name.EndsWith("\InstallPath")) { + $PythonInstallLocation = (Get-ItemProperty -LiteralPath $Installation.PSPath).'(default)' + return Join-Path $PythonInstallLocation "python.exe" + } + } + } } return $PythonExecutable