From 1adb18a83e0bcd92987f4c91223ac1b87f1cccb2 Mon Sep 17 00:00:00 2001 From: Mike Drakos Date: Wed, 9 Oct 2024 11:06:15 -0700 Subject: [PATCH] Set environment variable on shell detection --- installers/install.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/installers/install.ps1 b/installers/install.ps1 index ae30d9a78a..12d10e20da 100644 --- a/installers/install.ps1 +++ b/installers/install.ps1 @@ -147,6 +147,14 @@ function error([string] $msg) Write-Host $msg -ForegroundColor Red } +function setShellOverride { + $parentProcess = Get-WmiObject Win32_Process | Where-Object { $_.ProcessId -eq $PID } + $parentProcessDetails = Get-WmiObject Win32_Process | Where-Object { $_.ProcessId -eq $parentProcess.ParentProcessId } + if ($parentProcessDetails.Name -eq "cmd" -or $parentProcessDetails.Name -eq "cmd.exe") { + [System.Environment]::SetEnvironmentVariable("ACTIVESTATE_CLI_SHELL_OVERRIDE", $parentProcessDetails.Name, "Process") + } +} + $version = $script:VERSION if (!$version) { # If the user did not specify a version, formulate a query to fetch the JSON info of the latest @@ -248,6 +256,7 @@ $PSDefaultParameterValues['*:Encoding'] = 'utf8' # Run the installer. $env:ACTIVESTATE_SESSION_TOKEN = $script:SESSION_TOKEN_VALUE +setShellOverride & $exePath $args --source-installer="install.ps1" $success = $? if (Test-Path env:ACTIVESTATE_SESSION_TOKEN)