can someone please tell me what is wrong with this code? I get an "invalid parameter" error back from wmi. just trying to download a file via BITS. thank you
Try
Dim classInstance As New ManagementObject("root\Microsoft\BITS\", "BitsClientJob", Nothing)
' Obtain [in] parameters for the method
Dim inParams As ManagementBaseObject = classInstance.GetMethodParameters("CreateJob")
' Add the input parameters.
inParams("DisplayName") = "test"
inParams("LocalFile") = "c:\test.zip"
inParams("RemoteUrl") = "http://myinternaltestbox/test.zip"
' Execute the method and obtain the return values.
Dim outParams As ManagementBaseObject = classInstance.InvokeMethod("CreateJob", inParams, Nothing)
' List outParams
txtResult.Text = "JobId: {0}" & outParams("JobId") & vbCrLf
txtResult.Text = txtResult.Text & "ReturnValue: {0}" & outParams("ReturnValue")
Catch err As ManagementException
MessageBox.Show("An error occurred while trying to execute the WMI method: " & err.Message)
End Try
Try
Dim classInstance As New ManagementObject("root\Microsoft\BITS\", "BitsClientJob", Nothing)
' Obtain [in] parameters for the method
Dim inParams As ManagementBaseObject = classInstance.GetMethodParameters("CreateJob")
' Add the input parameters.
inParams("DisplayName") = "test"
inParams("LocalFile") = "c:\test.zip"
inParams("RemoteUrl") = "http://myinternaltestbox/test.zip"
' Execute the method and obtain the return values.
Dim outParams As ManagementBaseObject = classInstance.InvokeMethod("CreateJob", inParams, Nothing)
' List outParams
txtResult.Text = "JobId: {0}" & outParams("JobId") & vbCrLf
txtResult.Text = txtResult.Text & "ReturnValue: {0}" & outParams("ReturnValue")
Catch err As ManagementException
MessageBox.Show("An error occurred while trying to execute the WMI method: " & err.Message)
End Try