For Windows builds HIGHER than 17713:
WSL uses the file /etc/wsl.conf
inside each Linux VM’s filesystem to configure its behavior. Add the following configuration settings (explained here) to /etc/wsl.conf
, creating that file if necessary:
[interop]
appendWindowsPath = false
Note that appendWindowsPath
must be under [interop]
for this to work. You may need to shutdown the current instance of WSL with wsl --shutdown
or wsl -t <Distribution>
for changes to take effect. You could also add the option enabled = false
, also under the [interop]
section, to disable the ability to launch Windows binaries from inside WSL.
For Windows builds LOWER than 17713:
WSL uses WSL_DISTRIBUTION_FLAGS Enumeration to configure its behavior. Here is the code snippet from wslapi.h
header file.
/* Flags specifying WSL behavior */
typedef enum
{
WSL_DISTRIBUTION_FLAGS_NONE = 0x0,
WSL_DISTRIBUTION_FLAGS_ENABLE_INTEROP = 0x1,
WSL_DISTRIBUTION_FLAGS_APPEND_NT_PATH = 0x2,
WSL_DISTRIBUTION_FLAGS_ENABLE_DRIVE_MOUNTING = 0x4
} WSL_DISTRIBUTION_FLAGS;
#define WSL_DISTRIBUTION_FLAGS_VALID (WSL_DISTRIBUTION_FLAGS_ENABLE_INTEROP | WSL_DISTRIBUTION_FLAGS_APPEND_NT_PATH | WSL_DISTRIBUTION_FLAGS_ENABLE_DRIVE_MOUNTING)
#define WSL_DISTRIBUTION_FLAGS_DEFAULT (WSL_DISTRIBUTION_FLAGS_ENABLE_INTEROP | WSL_DISTRIBUTION_FLAGS_APPEND_NT_PATH | WSL_DISTRIBUTION_FLAGS_ENABLE_DRIVE_MOUNTING)
At first launch, WSL uses the default flag = 0x7
(i.e. 0+1+2+4). If that flag = 0x5
(i.e. 0+1+4), the Windows NT path will not appended in the $PATH
environment variable. To find that flag’s registry value, open HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss
in Registry Editor aka. regedit.exe
. Open each subkey with UID values and match DistributionName
with your installed distribution name. Then edit/add the Flags
DWORD registry value to 0x5
.