Skip to content

Commit

Permalink
(GH-724) Set Env Vars to empty should remove vars
Browse files Browse the repository at this point in the history
Removing environment variables sets empty environment variables. This
is related to the changes for GH-303.

So determine if the value is null or empty, and perform the older
behavior.
  • Loading branch information
ferventcoder committed May 5, 2016
1 parent 4951356 commit ebda31d
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
function Set-EnvironmentVariable([string] $Name, [string] $Value, [System.EnvironmentVariableTarget] $Scope) {
Write-Debug "Calling Set-EnvironmentVariable with `$Name = '$Name', `$Value = '$Value', `$Scope = '$Scope'"

if ($Scope -eq [System.EnvironmentVariableTarget]::Process) {
return [Environment]::SetEnvironmentVariable($Name, $Value, $Scope)
if ($Scope -eq [System.EnvironmentVariableTarget]::Process -or $Value -eq $null -or $Value -eq '') {
return [Environment]::SetEnvironmentVariable($Name, $Value, $Scope)
}

[string]$keyHive = 'HKEY_LOCAL_MACHINE'
Expand Down

0 comments on commit ebda31d

Please sign in to comment.