Reputation: 11
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
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
Click Start, and select All Programs.
Click Microsoft Visual Studio 2008 and select Visual Studio Tools.
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.
Upvotes: -1