在远程机器上执行 WQL 查询

Execute WQL Query on Remote Machine

我将此 WMI library for executing WQL query in Go language. I am able to execute the sample code in local machine. However, I need to execute the WQL query on a remote machine. The documentation 用于我使用的 Query 方法,如下所示:

By default, the local machine and default namespace are used. These can be changed using connectServerArgs. See http://msdn.microsoft.com/en-us/library/aa393720.aspx for details.

但是,我不确定如何正确传递 connectServerArgs。 有人可以帮我做一个这个参数的示例声明以及如何将它传递给 Query 方法吗?

根据the docsConnectServer方法的签名是:

objwbemServices = .ConnectServer( _
  [ ByVal strServer ], _
  [ ByVal strNamespace ], _
  [ ByVal strUser ], _
  [ ByVal strPassword ], _
  [ ByVal strLocale ], _
  [ ByVal strAuthority ], _
  [ ByVal iSecurityFlags ], _
  [ ByVal objwbemNamedValueSet ] _
)

所以尝试这样的事情:

c.Query(wqlQery, dst, "your-remote.server.net or IP address", 
    "root\CIMV2", "DomainName\UserName", "secret password")