Class: Specinfra::Command::Windows::Base::RegistryKey

Inherits:
Specinfra::Command::Windows::Base show all
Defined in:
lib/specinfra/command/windows/base/registry_key.rb

Constant Summary collapse

REGISTRY_KEY_TYPES =
{
  :type_string       => 'String',
  :type_binary       => 'Binary',
  :type_dword        => 'DWord',
  :type_qword        => 'QWord',
  :type_multistring  => 'MultiString',
  :type_expandstring => 'ExpandString'
}

Class Method Summary collapse

Methods inherited from Specinfra::Command::Windows::Base

create

Class Method Details

.check_exists(key_name) ⇒ Object


12
13
14
15
# File 'lib/specinfra/command/windows/base/registry_key.rb', line 12

def check_exists(key_name)
  cmd = "(Get-Item 'Registry::#{key_name}') -ne $null"
  Backend::PowerShell::Command.new { exec cmd }
end

.check_has_property(key_name, key_property) ⇒ Object


17
18
19
20
# File 'lib/specinfra/command/windows/base/registry_key.rb', line 17

def check_has_property(key_name, key_property)
  cmd = "(Get-Item 'Registry::#{key_name}').GetValueKind('#{key_property[:name]}') -eq '#{REGISTRY_KEY_TYPES[key_property[:type]]}'"
  Backend::PowerShell::Command.new { exec cmd }
end

.check_has_value(key_name, key_property) ⇒ Object


22
23
24
25
26
# File 'lib/specinfra/command/windows/base/registry_key.rb', line 22

def check_has_value(key_name, key_property)
  value = convert_key_property_value key_property
  cmd = "(Compare-Object (Get-Item 'Registry::#{key_name}').GetValue('#{key_property[:name]}') #{value}) -eq $null"
  Backend::PowerShell::Command.new { exec cmd }
end