OK, I don't know how much luck I'll have getting an answer for this here, but here it goes :
I'm working on eliminating the batch file altogether, but am running into an "Access Denied" error when the invoke is called. WMI testing programs tell me everything should be fine. Here is the code :
Private Sub ExecuteFile(ByVal comp As ListViewItem)
Dim wmi As ManagementClass
Dim wmi_in, wmi_out As ManagementBaseObject
Dim retValue As Integer
Try
wmi = New ManagementClass("\\" & comp.Text & "\root\cimv2:Win32_Process")
' get the parameters to the Create method
wmi_in = wmi.GetMethodParameters("Create")
' fill in the command line plus any command-line arguments
' NOTE: the command can NOT be on a network resource!
wmi_in("CommandLine") = """" & My.Settings.ClientPath & "\lsclient.exe"" " & My.Settings.LSServer
' do it!
wmi_out = wmi.InvokeMethod("Create", wmi_in, Nothin)
' get the return code. This not the return code of the
' application... it's a return code for the WMI method
retValue = Convert.ToInt32(wmi_out("returnValue"))
Select Case retValue
Case 0
' success!
CompFinishedList.Add(comp)
Case 2
Throw New ApplicationException("Access denied")
Case 3
Throw New ApplicationException("Insufficient privilege")
Case 8
Throw New ApplicationException("Unknown failure")
Case 9
Throw New ApplicationException("Path not found")
Case 21
Throw New ApplicationException("Invalid parameter")
Case Else
Throw New ApplicationException("Unknown return code " & retValue)
End Select
Catch ex As ApplicationException
If Not CompErrorList.Contains(comp) Then
CompErrorList.Add(comp)
End If
MsgBox(ex.Message)
End Try
End Sub
I've also been running into this error when executing the batch file lately, but it isn't WMI that returns the error, just the following line in the .bat :
\\Path\To\Client\lsclient.exe server
Running the command from a prompt works fine, even as a regular user, but from the batch it fails every time. Except, of course, on my machine, as well as a test server I have sitting next to me.
Anyone have any ideas?
EDIT : The WMI error code is 2147217407. Searching Google for info now.
EDIT : Nevermind. Resolved.