I have installed ubuntu 18.04 on wsl2. I know that with the command 'code .' you can open VS Code, but I want to know is there a commands for all Apps that u can open them from wsl2 terminal, like for example command for Visual Studio?
I have installed ubuntu 18.04 on wsl2. I know that with the command 'code .' you can open VS Code, but I want to know is there a commands for all Apps that u can open them from wsl2 terminal, like for example command for Visual Studio?
By default, WSL has "Interop" enabled, which allows you to run/launch any Windows executable from within WSL. Also by default, WSL appends the Windows path to your WSL path (also controlled in the same Interop section of /etc/wsl.confg).
So as long as the Windows application is in the path, appname.exe will work. For instance, notepad.exe will launch Notepad.
The reason that you don't need the .exe with VSCode is because the Windows version provides a shell script (code) that is designed to work with WSL.
For apps that are not on the path, you can either edit the WSL path (in, for instance, your .bashrc) or provide the full path like:
/mnt/c/Program\ Files/Windows\ Photo\ Viewer/ImagingDevices.exe
Note that you need to account for the difference between Linux/POSIX path and the Windows equivalent. For instance:
notepad.exe ~/test.txt
... will not work, since Notepad won't understand the Linux path. WSL provides the wslpath command to translate paths:
notepad.exe $(wslpath -w ~/test.txt)
or
notepad.exe '\\wsl$\Ubuntu\home\username\test.txt'
Please note: This is a bad example, just to make it easy to understand. Do not use notepad.exe to edit Linux files, as Notepad will add CRLF (DOS line-endings) which Linux apps will not handle properly.