Class: Specinfra::Command::Windows::Base::Process

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

Class Method Summary collapse

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

create

Class Method Details

.check_process(process) ⇒ Object



3
4
5
6
7
# File 'lib/specinfra/command/windows/base/process.rb', line 3

def check_process(process)
  Backend::PowerShell::Command.new do
    exec "(Get-Process '#{process}') -ne $null"
  end
end

.get(process, opts) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/specinfra/command/windows/base/process.rb', line 9

def get(process, opts)
  column = opts[:format].chomp '='

  case column
  when 'pid'
    # map 'pid' to its windows equivalent
    get_process_property(process, 'processid')
  when 'user'
    %Q!gwmi win32_process -filter "name = '#{process}'" | select -first 1 | %{$_.getowner().user}!
  when 'group'
    # no concept of process group on Windows
    raise NotImplementedError.new('Unable to get process group on Windows')
  else
    get_process_property(process, column)
  end
end