Method: PSWindows::Exec#clear_env_var

Defined in:
lib/beaker/host/pswindows/exec.rb

#clear_env_var(key) ⇒ Object

Delete the environment variable from the current ssh environment

Examples:

host.clear_env_var('PATH')

Parameters:

  • key (String)

    The key to delete



143
144
145
146
147
148
149
# File 'lib/beaker/host/pswindows/exec.rb', line 143

def clear_env_var key
  key = key.to_s.upcase
  exec(powershell("[Environment]::SetEnvironmentVariable('#{key}', $null, 'Machine')"))
  exec(powershell("[Environment]::SetEnvironmentVariable('#{key}', $null, 'User')"))
  exec(powershell("[Environment]::SetEnvironmentVariable('#{key}', $null, 'Process')"))
  self.close #refresh the state
end