diff --git a/lib/wmi.js b/lib/wmi.js index 9c091e9..adfdce5 100644 --- a/lib/wmi.js +++ b/lib/wmi.js @@ -6,19 +6,24 @@ var WMIObject = function() { var wbemFlagReturnImmediately = 0x10; var wbemFlagForwardOnly = 0x20; + this.server = "."; this.interface = null; this.cursor = {}; this.current = {}; this.create = function() { - this.interface = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2"); + this.interface = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" + this.server + "\\root\\cimv2"); + return this; + }; + this.setServer = function(server) { + this.server = server; return this; }; this.execQuery = function(query) { try { var result = this.interface.ExecQuery(query, "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); this.cursor = new Enumerator(result); - } catch(e) { + } catch (e) { console.error(e.message); } return this;