VB.Net - 使用用户凭据的本地 WMI 连接

Mit*_*hel 2 vb.net wmi local

在 VB.Net 中,我尝试使用不同的凭据(用户没有管理员权限)连接到本地计算机上的 WMI,但出现此异常:

« 用户凭据不能用于本地连接 »

这是代码:

    Dim path As ManagementPath = Nothing
    Dim options As ConnectionOptions = Nothing
    Dim scope As ManagementScope = Nothing

    path = New ManagementPath("\\" & vServerName & "\root\CIMV2")

    options = New ConnectionOptions
    options.Username = vUsername
    options.Password = vPassword

    Scope = New ManagementScope(path, options)

    Scope.Connect()
Run Code Online (Sandbox Code Playgroud)

Rob*_*ert 5

我知道这个问题很老,但我尝试了上述步骤,但没有奏效。我发现工作是这样的:

https://web.archive.org/web/20150213044821/http://www.manageengine.com/network-monitoring/help/troubleshoot_opmanager/troubleshoot_wmi.html

80041064 - 用户凭据不能用于本地连接

原因

当您指定用户名和密码来监控运行 OpManager 的机器时会遇到此错误。

解决方案

不要为本地主机指定用户名和密码。要解决此问题,请从设备快照页面的“密码”链接中删除配置的用户名和密码。