WSManConnectShellCommand function (wsman.h)

Connects to an existing command running in a shell.


void WSManConnectShellCommand(
  [in, out]      WSMAN_SHELL_HANDLE   shell,
                 DWORD                flags,
  [in]           PCWSTR               commandID,
  [in, optional] WSMAN_OPTION_SET     *options,
  [in, optional] WSMAN_DATA           *connectXml,
  [in]           WSMAN_SHELL_ASYNC    *async,
  [out]          WSMAN_COMMAND_HANDLE *command


[in, out] shell

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


Reserved for future use. Must be zero.

[in] commandID

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

[in, optional] options

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.

[in, optional] connectXml

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.

[in] async

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.

[out] command

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



Minimum supported client Windows 8
Minimum supported server Windows Server 2012
Target Platform Windows
Header wsman.h
Library WsmSvc.lib
DLL WsmSvc.dll