From 22a778ee4c792a3a58fff033892b6620538794df Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Wed, 11 Feb 2015 07:30:10 -0600 Subject: [PATCH] (GH-7) warn when install is not done in admin mode If the environment variables are being created as USER instead of SYSTEM, warn the user about this so they can take manual actions if this is not what they wanted. --- nuget/chocolatey/tools/chocolateysetup.psm1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nuget/chocolatey/tools/chocolateysetup.psm1 b/nuget/chocolatey/tools/chocolateysetup.psm1 index 4eeee38e45..cdeece8cda 100644 --- a/nuget/chocolatey/tools/chocolateysetup.psm1 +++ b/nuget/chocolatey/tools/chocolateysetup.psm1 @@ -122,11 +122,15 @@ param( [string]$folder ) $environmentTarget = [System.EnvironmentVariableTarget]::User + # removing old variable Install-ChocolateyEnvironmentVariable -variableName "$chocInstallVariableName" -variableValue $null -variableType $environmentTarget if (Test-ProcessAdminRights) { Write-Debug "Administrator installing so using Machine environment variable target instead of User." $environmentTarget = [System.EnvironmentVariableTarget]::Machine + # removing old variable Install-ChocolateyEnvironmentVariable -variableName "$chocInstallVariableName" -variableValue $null -variableType $environmentTarget + } else { + Write-Warning "Setting ChocolateyInstall Environment Variable on USER and not SYSTEM variables.`n This is due to either non-administrator install OR the process you are running is not being run as an Administrator." } Write-Output "Creating $chocInstallVariableName as an environment variable (targeting `'$environmentTarget`') `n Setting $chocInstallVariableName to `'$folder`'" @@ -297,6 +301,8 @@ param( if (Test-ProcessAdminRights) { Write-Debug "Administrator installing so using Machine environment variable target instead of User." $environmentTarget = [System.EnvironmentVariableTarget]::Machine + } else { + Write-Warning "Setting ChocolateyInstall Path on USER PATH and not SYSTEM Path.`n This is due to either non-administrator install OR the process you are running is not being run as an Administrator." } Install-ChocolateyPath -pathToInstall "$chocolateyExePath" -pathType $environmentTarget