How can I make a Windows shortcut that launches Bash and runs commands?
If this is WSL, use bash.exe -c "command to run" as in
C:\Windows\System32\bash.exe -c "vi ~/.bashrc"
or
C:\Windows\System32\bash.exe -c "php /mnt/c/script.php"
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.