diff options
Diffstat (limited to 'lib/wmi-lite/wmi.rb')
-rw-r--r-- | lib/wmi-lite/wmi.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/wmi-lite/wmi.rb b/lib/wmi-lite/wmi.rb index 61fd0c3..1acc9bd 100644 --- a/lib/wmi-lite/wmi.rb +++ b/lib/wmi-lite/wmi.rb @@ -54,7 +54,16 @@ module WmiLite private def start_query(wql_query) - @connection.ExecQuery(wql_query) + result = @connection.ExecQuery(wql_query) + raise_if_failed(result) + result + end + + def raise_if_failed(result) + # Attempting to access the count property of the underlying + # COM (OLE) object will trigger an exception if the query + # was unsuccessful. + result.count end def new_connection(namespace) |