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