How do I start Edge on Windows from WSL2?

Viewed 7923

I can run code to start VSCode from inside WSL2.

How would I start Edge (the current Chromium based one)?

I have tried:

~/Code/company/workshops-website$ cmd.exe /c 'start microsoft-edge:\\wsl$\Ubuntu\home\mike\Code\company\workshops-website\index.html'
'\\wsl$\Ubuntu\home\mike\Code\company\workshops-website'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.

It starts Edge but doesn't open index.html (instead Edge searches for it)

How would I start Edge (the Windows app) from inside WSL2?

I'm comfortable making bash aliases, functions, etc.

5 Answers

$ wslview index.html

Will open the file in your default browser on Windows.

wslview is packaged in wslutilities which comes pre-installed on Ubuntu on WSL and some other WSL distros.

If you wish to use the default Windows browser automatically, e.g. when using 'az login', add these lines to your shell's RC e.g. .bashrc or .zshrc:

export DISPLAY=:0
export BROWSER=/usr/bin/wslview

I think the best way to do this is to use explorer.exe. You can use explorer.exe to open anything web related in your default browser.

So edit your .bash_aliases (or create it) to add this line:

alias browser="explorer.exe"

Then you can open your HTML files in your default browser like this:

$ browser index.html

I think you can try this

Add this line:

alias browser="/mnt/c/Program\ Files\ \(x86\)/Microsoft/Edge/Application/msedge.exe"

to .bashrc the value is the path of my browser so if you type browser, the microsoft edge will pop up just like type code and vscode pops up

It seems to differ depending on Distro (according to the other answers). For instance, I have Kali installed in the WSL2 (Windows 11) and if I want to run the new Edge from there, I first have to install it, Edge-Developer Edition Install Debain-based, Regular Edge. The second link, you need to scroll all the way to the bottom and pick Linux from the drop-down menu. Once installed it will be in your "Start Menu". Again, I am using Kali and have not tried the others lately on the WSL, but as far as Kali is concerned, as long as the WSL is running, you can launch any Linux program from the Windows Start Menu!. You only really need a desktop env, if you need a Linux desktop env, otherwise just use the apps alongside Windows...I love it! WSL2 Running. No Commands. Apps Running

Again, this may be "Distro-specific", but in the picture I tried to show how I can launch apps that are installed in the WSL without any commands or changing desktop environments in order for them to run. Same goes for Edge, I suggest download the .deb file and installing it that way.

Related