Sha256: a7aed58993ae8c3af04718e386e191cb095f798d40d0c542678953e1a6db0a71

Contents?: true

Size: 993 Bytes

Versions: 230

Compression:

Stored size: 993 Bytes

Contents

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

    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

    private
    def get_process_property(process, property)
      %Q!Get-WmiObject Win32_Process -Filter "name = '#{process}'" | select -First 1 #{property} -ExpandProperty #{property}!
    end
  end
end

Version data entries

230 entries across 230 versions & 3 rubygems

Version Path
specinfra-2.91.0 lib/specinfra/command/windows/base/process.rb
specinfra-2.90.1 lib/specinfra/command/windows/base/process.rb
specinfra-2.90.0 lib/specinfra/command/windows/base/process.rb
specinfra-2.89.0 lib/specinfra/command/windows/base/process.rb
specinfra-2.88.2 lib/specinfra/command/windows/base/process.rb
specinfra-2.88.1 lib/specinfra/command/windows/base/process.rb
specinfra-2.88.0 lib/specinfra/command/windows/base/process.rb
specinfra-2.87.2 lib/specinfra/command/windows/base/process.rb
specinfra-2.87.1 lib/specinfra/command/windows/base/process.rb
specinfra-2.87.0 lib/specinfra/command/windows/base/process.rb
specinfra-2.86.0 lib/specinfra/command/windows/base/process.rb
specinfra-2.85.1 lib/specinfra/command/windows/base/process.rb
specinfra-2.85.0 lib/specinfra/command/windows/base/process.rb
specinfra-2.84.1 lib/specinfra/command/windows/base/process.rb
specinfra-2.84.0 lib/specinfra/command/windows/base/process.rb
specinfra-2.83.4 lib/specinfra/command/windows/base/process.rb
specinfra-2.83.3 lib/specinfra/command/windows/base/process.rb
specinfra-2.83.2 lib/specinfra/command/windows/base/process.rb
specinfra-2.83.1 lib/specinfra/command/windows/base/process.rb
specinfra-2.83.0 lib/specinfra/command/windows/base/process.rb