class Win32Ole

Constants

ImpersonationLevel
RPC_C_IMP_LEVEL_IMPERSONATE

Public Class Methods

new() click to toggle source
# File lib/facter/resolvers/windows/utils/win32ole.rb, line 7
def initialize
  locator = WIN32OLE.new('WbemScripting.SWbemLocator')
  @conn = locator.ConnectServer('.', 'root\\cimv2')
  @conn.Security_.ImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE
end

Public Instance Methods

exec_query(query) click to toggle source
# File lib/facter/resolvers/windows/utils/win32ole.rb, line 20
def exec_query(query)
  @conn.execquery(query)
end
return_first(query) click to toggle source
# File lib/facter/resolvers/windows/utils/win32ole.rb, line 13
def return_first(query)
  result = exec_query(query)
  return result.to_enum.first if result

  nil
end