MI_Application_NewSession function

Creates a session used to share connections for a set of operations to a single destination.


 MI_INLINE MI_Result MI_Application_NewSession(
  _In_           MI_Application                            *application,
  _In_opt_ const MI_Char                                   *protocol,
  _In_opt_ const MI_Char                                   *destination,
  _In_opt_       MI_DestinationOptions                     *options,
  _In_opt_       MI_SessionCallbacks                       *callbacks,
                 _Outptr_opt_result_maybenull_ MI_Instance **extendedError,
  _Out_          MI_Session                                *session


application [in]

A pointer to a handle returned from the MI_Application_Initialize function.

protocol [in, optional]

A pointer to an optional protocol handler to carry out the operation. If this parameter is NULL, a default value is used, based on the destination. Currently supported protocols are L"WMIDCOM" and L"WINRM".

destination [in, optional]

An optional destination for the session. If the destination argument is NULL, the session communicates with the local machine. Otherwise, the destination can be the computer name of the local machine or a remote machine.

options [in, optional]

A pointer to optional destination options, such as default time-outs and credentials.

callbacks [in, optional]

A pointer to an optional MI_SessionCallbacks structure that contains callbacks to receive various results.


Pointer to optional additional error information if the operation failed. When you have finished using the error information, free the memory by calling the MI_Instance_Delete function.

session [out]

A pointer to the returned session handle. When you have finished using the session handle, close it by calling the MI_Session_Close function. If the session handle is not closed before shutting down both the application and the application handle, the application handle shutdown will not respond.

Return value


The operation succeeded.


There is not enough memory to complete the request.


One or more parameters passed to the function were not valid.


A failure not covered by other MI_Result error codes.


Creating a destination may not communicate with the destination computer. It will not be until the first operation is carried out on a session that the application can determine whether the computer is accessible.

The MI_Session_Close function must be called on the outbound session handle. Close all operations under the target session before closing the session.

If no protocol is specified and destination is NULL, the WMIDCOM protocol is used. If no protocol is specified and destination is not NULL, the WINRM protocol is used. .


Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012


Windows Management Framework 3.0 on Windows Server 2008 R2 with SP1, Windows 7 with SP1, and Windows Server 2008 with SP2



See also

Windows Remote Management