diff --git a/src/Tools/DynamoInstallDetective/AscSDKWrapper.cs b/src/Tools/DynamoInstallDetective/AscSDKWrapper.cs index 71c3301c529..428dd9db6e5 100644 --- a/src/Tools/DynamoInstallDetective/AscSDKWrapper.cs +++ b/src/Tools/DynamoInstallDetective/AscSDKWrapper.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using Microsoft.Win32; @@ -156,9 +157,29 @@ public ASC_STATUS GetInstalledPath(ref string installedPath) return ASC_STATUS.INITIALIZE_FAILED; } + if (!string.IsNullOrEmpty(installPath)) + { + installedPath = installPath; + return ASC_STATUS.SUCCESS; + } + var status = ReadASCVersionFromEnv() == ASC_STATUS.SUCCESS ? ASC_STATUS.SUCCESS : ReadASCInstallPathFromRegistry(majorRelease); - installedPath = installPath; + if (status == ASC_STATUS.SUCCESS) + { + try + { + string currentPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process); + string updatedPath = currentPath + ";" + installPath; + Environment.SetEnvironmentVariable("PATH", updatedPath, EnvironmentVariableTarget.Process); + } + catch + { + Trace.WriteLine("Failed to update path for ASC component"); + } + } + + installedPath = installPath; return status; }