Hello,

For some reason the following code works perfectly fine if a user is logged into a machine but if no one is logged in, I receive the error message "Call was canceled by the message filter. (Exception from HRESULT: 0x80010002 (RPC_E_CALL_CANCELED))"

I know it is possible somehow to create the service on the remote machine even if a user is not logged in but what must I change in my code??

Code:
	Private Function CreateRemoteService(ByVal HostName As String, ByVal Name As String, ByVal DisplayName As String, ByVal Process As String) As Boolean
		Try
			Dim wmiOptions As New ConnectionOptions

			wmiOptions.Impersonation = ImpersonationLevel.Impersonate
			wmiOptions.Authentication = AuthenticationLevel.PacketPrivacy

			Dim wmiPath As New ManagementPath("\\" & HostName & "\root\cimv2:Win32_Service")
			Dim wmiScope As New ManagementScope(wmiPath, wmiOptions)

			wmiScope.Connect()

			Dim wmiGetOptions As New ObjectGetOptions

			Dim wmi_Win32_Process_Class As New ManagementClass(wmiScope, wmiPath, wmiGetOptions)
			Dim wmi_inParams As ManagementBaseObject = wmi_Win32_Process_Class.GetMethodParameters("Create")

			wmi_inParams("Name") = Name
			wmi_inParams("DisplayName") = DisplayName
			wmi_inParams("PathName") = Process
			wmi_inParams("StartMode") = "Manual"
			wmi_inParams("DesktopInteract") = True

			Dim wmi_outParams As ManagementBaseObject = wmi_Win32_Process_Class.InvokeMethod("Create", wmi_inParams, Nothing)

			CreateRemoteService = True
		Catch ex As Exception
			MsgBox(ex.Message)
			CreateRemoteService = False
		End Try
	End Function