WSManRunShellCommand function (wsman.h)

Starts the execution of a command within an existing shell and does not wait for the completion of the command.


void WSManRunShellCommand(
  DWORD                 flags,
  PCWSTR                commandLine,
  WSMAN_OPTION_SET      *options,
  WSMAN_SHELL_ASYNC     *async,



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


Reserved for future use. Must be zero.


Defines a required null-terminated string that represents the command to be executed. Typically, the command is specified without any arguments, which are specified separately. However, a user can specify the command line and all of the arguments by using this parameter. If arguments are specified for the commandLine parameter, the args parameter should be NULL.


A pointer to a WSMAN_COMMAND_ARG_SET structure that defines an array of argument values, which are passed to the command on creation. If no arguments are required, this parameter should be NULL.


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.


Defines an asynchronous structure. The asynchronous structure contains an optional user context and a mandatory callback function. See the WSMAN_SHELL_ASYNC structure for more information. This parameter cannot be NULL and should be closed by calling the WSManCloseCommand method.


Defines the command object associated with a command within a shell. This handle is returned on a successful call and is used to send and receive data and to signal the command. This handle should be closed by calling the WSManCloseCommand method. This parameter cannot be NULL.

Return value



Minimum supported client Windows 7
Minimum supported server Windows Server 2008 R2
Target Platform Windows
Header wsman.h
Library WsmSvc.lib
DLL WsmSvc.dll
Redistributable Windows Management Framework on Windows Server 2008 with SP2 and Windows Vista with SP2