user3750676
user3750676

Reputation: 11

WMI Provider load failure

I am getting the following error for the code below, on the "Next Line (line 10). Any ideas?

System.Management.ManagementException occurred
  Message=Provider load failure 
  Source=System.Management
  StackTrace:
       at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
       at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()

Here is the code:

Using mos As ManagementObjectSearcher = New ManagementObjectSearcher("SELECT * FROM Win32_Process")
For Each mo As ManagementObject In mos.Get()
    Dim name As String = mo("Name")
    Dim commandLine As String = mo("CommandLine")
    If name = "rundll32.exe" Then
        Dim index As Integer
        commandLine = commandLine.Substring(index).ToLower
        processPath = commandLine
    End If
  Next
End Using

Upvotes: 1

Views: 2230

Answers (1)

Mr.O
Mr.O

Reputation: 37

https://msdn.microsoft.com/en-us/library/bb961987.aspx

WMI clients can get a Provider Load Failure error when they attempt to use functionality implemented in a WMI provider that leverages the WMI Provider Extensions infrastructure. The cause might be an improperly-registered dynamic-link library (DLL). During installation of the .NET Framework 3.5 (prior to SP1), the DLL named System.Management.Instrumentation.dll is not properly registered. To perform the registration, run the Regasm.exe tool providing the full path to the DLL as the only argument. The following procedure provides step-by-step directions to properly register System.Management.Instrumentation.dll. Register System.Management.Instrumentation.dll

  1. Click Start, and select All Programs.

  2. Click Microsoft Visual Studio 2008 and select Visual Studio Tools.

  3. On operating systems before Windows Vista, click Microsoft Visual Studio 2008 Command Prompt to open a command prompt window. On Windows Vista, right-click Microsoft Visual Studio 2008 Command Prompt and select Run as Administrator to open an elevated command prompt window.

  4. At the command prompt, type "regasm %systemdrive%\program files\reference assemblies\microsoft\framework\v3.5\system.management.instrumentation.dll" and press ENTER.
  5. Check for the message, Types registered successfully. To verify that the registration has been corrected, you can run the WSH script below. It should output System.Management.Instrumentation for .NET Framework 3.5 is already registered.

Upvotes: -1

Related Questions