Skip to main content
WSManConnectShellCommand function

Connects to an existing command running in a shell.


void WINAPI WSManConnectShellCommand(
  _Inout_  WSMAN_SHELL_HANDLE shell,
           DWORD              flags,
  _In_     PCWSTR             commandID,
  _In_opt_ WSMAN_OPTION_SET   *options,
  _In_opt_ WSMAN_DATA         *connectXml,
  _In_     WSMAN_SHELL_ASYNC  *async,
  _Out_    WSMAN_SHELL_HANDLE *command


shell [in, out]

Specifies the shell handle returned by the WSManCreateShell call. This parameter cannot be NULL.


Reserved for future use. Must be zero.

commandID [in]

A null-terminated string that identifies a specific command, currently running in the server session, that the client intends to connect to.

options [in, optional]

Defines a set of options for the command. These options are passed to the service to modify or refine the command execution. This parameter can be NULL. For more information about the options, see WSMAN_OPTION_SET.

connectXml [in, optional]

A pointer to a WSMAN_DATA structure that defines an open context for the connect shell operation. The content must be a valid XML string. This parameter can be NULL.

async [in]

Defines an asynchronous structure to contain an optional user context and a mandatory callback function. For more information, see WSMAN_SHELL_ASYNC. This parameter cannot be NULL.

command [out]

This handle is returned on a successful call and is used to send and receive data and to signal the command. When you have finished using this handle, close it by calling the WSManCloseCommand method. This parameter cannot be NULL.

Return value

This function does not return a value.


Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012