WSL: "explorer.exe: command not found" when user changed

  • Windows 10.0.19536.1000

  • What you’re doing and what’s happening:

Login as normal user.

Change user to root

Then try explorer.exe .

  • What’s wrong / what should be happening instead:

expected opening of Explorer in Windows but explorer.exe: command not found

image

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

As a temporary workaround, by changing the default user for wsl allows you to see the user files in windows. open PowerShell in Admin mode ubuntu2004.exe config --default-user <username>

No , it did not work for me

(/mnt/c/Windows/explorer.exe .) use this instead of just (explorer.exe .)

I ran into the same problem. when I first startup Ubuntu-18.04 in WSL and echo PATH, System32 was included, these commands such as explorer.exe . can ran normally. But if I switch user to root, that problem just came up, echo PATH shows no System32

explorer.exe . should show the current path in wsl - correct? For me it doesn’t work. Explorer starts in my documents instead. So how do I open the explorer inside the WSL-Path? \wsl$ does also not working. (10 Pro 21H2 19044.2311)

alias explorer.exe='/mnt/c/Windows/explorer.exe echo ‘PATH=$PATH:/mnt/c/windows’ >> ~/.bashrc

These two commands worked for me, thank you so much!

thanks to your method,I can use explorer.exe again.but I still want to know the reason behind it.

Because the the path /mnt/c/Windows/explorer.exe isn’t being associated with explorer.exe. One fix, as mentioned, is to just add it as an alias: alias explorer.exe='/mnt/c/Windows/explorer.exe.

As a temporary workaround, by changing the default user for wsl allows you to see the user files in windows. open PowerShell in Admin mode ubuntu2004.exe config --default-user <username>

It doesn’t worked for me, but I tried to set the user in the command line that launch the distro:

Note: I’m using the Windows Terminal

  1. Go to config of Ubuntu terminal
  2. In the section “Command line” set the command: ubuntu2004.exe -u <username> or wsl ~ -d Ubuntu-20.04 -u <username>

    It will start the Ubuntu terminal as the specified user. Note: If you are using another version of Ubuntu, just replace the version in the command.

  3. Save and start the Ubuntu terminal in another tab a see if the explorer.exe . works. (worked for me)

As a temporary workaround, by changing the default user for wsl allows you to see the user files in windows. open PowerShell in Admin mode ubuntu2004.exe config --default-user <username>

Run echo $PATH. It should contain /mnt/c/Windows/system32. Did you add any config in /etc/wsl.conf?

As a temporary workaround, by changing the default user for wsl allows you to see the user files in windows. open PowerShell in Admin mode ubuntu2004.exe config --default-user <username>

No , it did not work for me

(/mnt/c/Windows/explorer.exe .) use this instead of just (explorer.exe .)

thanks to your method,I can use explorer.exe again.but I still want to know the reason behind it.

That’s by design Linux. If you sudo su you get root’s path, not you roro path.