Class: Vagrant::Notify::Action::Windows::ProcessInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-notify/action/windows/process_info.rb

Class Method Summary collapse

Class Method Details

.queryProcess(pid) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vagrant-notify/action/windows/process_info.rb', line 7

def self.queryProcess(pid)
  return false unless pid =~ /\A\d+\z/
  result = `c\:/Windows/System32/wbem/WMIC.exe process where \"ProcessID = '#{pid}'\" get ProcessID,Commandline /format:list 2>nul`
  querypid = false
  result.split(/\r?\n/).each do |line|
    next if line =~ /^\s*$/
    if line =~ /ProcessId=(\d+)/i
        querypid = $1.to_i
    end
  end
  return querypid
end