Skip to main content
The link https://docs.microsoft.com/en-us/windows/wsl/interop does not contain 'deprec', whereas https://docs.microsoft.com/en-us/windows/wsl/basic-commands#deprecated-wsl-commands does. (This might have been different in 2019 when the answer was written.) Also, it should be _two different_ links.
Source Link

First of all, bash.exe has been deprecatedbash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:

wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php

Here is the wsl.exe usage information:

Usage: wsl.exe [Argument] [Options...] [CommandLine][Command]

Arguments to run Linux binaries:

If no command line is provided, wsl.exe launches the default shell.

--exec, -e <CommandLine><Command>
    Execute the specified command without using the default Linux shell.

--
    Pass the remaining command line as is.

For further details, read WSL interoperabiltity with WindowsWSL interoperability with Windows.

First of all, bash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:

wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php

Here is the wsl.exe usage information:

Usage: wsl.exe [Argument] [Options...] [CommandLine]

Arguments to run Linux binaries:

If no command line is provided, wsl.exe launches the default shell.

--exec, -e <CommandLine>
    Execute the specified command without using the default Linux shell.

--
    Pass the remaining command line as is.

For further details, read WSL interoperabiltity with Windows.

First of all, bash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:

wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php

Here is the wsl.exe usage information:

Usage: wsl.exe [Argument] [Options...] [Command]

Arguments to run Linux binaries:

If no command line is provided, wsl.exe launches the default shell.

--exec, -e <Command>
    Execute the specified command without using the default Linux shell.

--
    Pass the remaining command line as is.

For further details, read WSL interoperability with Windows.

Commonmark migration
Source Link

First of all, bash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:

wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php

Here is the wsl.exe usage information:

Usage: wsl.exe [Argument] [Options...] [CommandLine]

Arguments to run Linux binaries:

If no command line is provided, wsl.exe launches the default shell.

--exec, -e <CommandLine>
    Execute the specified command without using the default Linux shell.

--
    Pass the remaining command line as is.

For further details, read WSL interoperabiltity with Windows.

First of all, bash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:

wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php

Here is the wsl.exe usage information:

Usage: wsl.exe [Argument] [Options...] [CommandLine]

Arguments to run Linux binaries:

If no command line is provided, wsl.exe launches the default shell.

--exec, -e <CommandLine>
    Execute the specified command without using the default Linux shell.

--
    Pass the remaining command line as is.

For further details, read WSL interoperabiltity with Windows.

First of all, bash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:

wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php

Here is the wsl.exe usage information:

Usage: wsl.exe [Argument] [Options...] [CommandLine]

Arguments to run Linux binaries:

If no command line is provided, wsl.exe launches the default shell.

--exec, -e <CommandLine>
    Execute the specified command without using the default Linux shell.

--
    Pass the remaining command line as is.

For further details, read WSL interoperabiltity with Windows.

Source Link
Biswapriyo
  • 11.3k
  • 10
  • 48
  • 80

First of all, bash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:

wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php

Here is the wsl.exe usage information:

Usage: wsl.exe [Argument] [Options...] [CommandLine]

Arguments to run Linux binaries:

If no command line is provided, wsl.exe launches the default shell.

--exec, -e <CommandLine>
    Execute the specified command without using the default Linux shell.

--
    Pass the remaining command line as is.

For further details, read WSL interoperabiltity with Windows.