WslLaunch function (wslapi.h)

Launches a Windows Subsystem for Linux (WSL) process in the context of a particular distribution.

Syntax

HRESULT WslLaunch(
  [in]           PCWSTR distributionName,
  [in, optional] PCWSTR command,
  [in]           BOOL   useCurrentWorkingDirectory,
  [in]           HANDLE stdIn,
  [in]           HANDLE stdOut,
  [in]           HANDLE stdErr,
  [out]          HANDLE *process
);

Parameters

[in] distributionName

Unique name representing a distribution (for example, "Fabrikam.Distro.10.01").

[in, optional] command

Command to execute. If no command is supplied, launches the default shell.

[in] useCurrentWorkingDirectory

Governs whether or not the launched process should inherit the calling process's working directory. If FALSE, the process is started in the WSL default user's home directory ("~").

[in] stdIn

Handle to use for STDIN.

[in] stdOut

Handle to use for STDOUT.

[in] stdErr

Handle to use for STDERR.

[out] process

Pointer to address to receive the process HANDLE associated with the newly-launched WSL process.

Return value

Returns S_OK on success, or a failing HRESULT otherwise.

Remarks

Caller is responsible for calling CloseHandle on the value returned in phProcess on success.

Requirements

Requirement Value
Target Platform Windows
Header wslapi.h
Library Wslapi.lib
DLL Api-ms-win-wsl-api-l1-1-0.dll