linux powershell

Open PowerShell from WSL Bash with Absolute File Path

I'll introduce how to pass an absolute path file from WSL Linux bash command line to PowerShell and open it. Apparently, WSL bash is not good at opening files with absolute paths. With <code>cmd /c</code>, you can use absolute paths starting with <code>C:/</code>, but... The term '' is not recognized as the name of a cmdlet...

Shou Arisaka
2 min read
Nov 21, 2025

I’ll introduce how to pass an absolute path file from WSL Linux bash command line to PowerShell and open it.

Apparently, WSL bash is not good at opening files with absolute paths. With cmd /c, you can use absolute paths starting with C:/, but with PowerShell, even if you do powershell . C:/hoge/hoge.mp4

This happens.

$ psl . C:\_videos\agd\video_20180824_104256.mp4
. : The term 'C:_videosagdvideo_20180824_104256.mp4' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:3
+ . C:_videosagdvideo_20180824_104256.mp4
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (C:_videosagdvideo_20180824_104256.mp4:String) [], CommandNotFoundExcept
ion
+ FullyQualifiedErrorId : CommandNotFoundException

How about /mnt/ paths then?

$ psl . /mnt/c/_videos/agd/video_20180824_104256.mp4
. : The term '/mnt/c/_videos/agd/video_20180824_104256.mp4' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:3
+ . /mnt/c/_videos/agd/video_20180824_104256.mp4
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (/mnt/c/_videos/...0824_104256.mp4:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

So, absolute paths just can’t be opened. Well, I mean, they can be opened from command prompt… but converting /mnt/ → C: every time… and I recently learned about the wslpath command but I can’t use it for some reason… Well, it’s in beta, so I think it’s faster to overcome such bugs on my own rather than waiting for fixes.

So, since absolute paths are impossible, let’s convert to relative paths and open the file.

According to shell - Convert absolute path into relative path given a current directory using Bash - Stack Overflow,

python -c "import os.path; print os.path.relpath('[absolute path of target file]', '[current path]')"

It seems you can calculate the relative path with a Python one-liner like this. Ruby’s expand_path(”,FILE) would probably work too.

So, I’ll do this:

$ python -c "import os.path; print os.path.relpath('/mnt/c/_videos/agd/video_20180824_104256.mp4', '$(echo $PWD)')"
../_videos/agd/video_20180824_104256.mp4

Looks good.

psl . $(python -c "import os.path; print os.path.relpath('/mnt/c/_videos/agd/video_20180824_104256.mp4', '$(echo $PWD)')")

… It opened. (psl is a custom alias for powershell.exe.)

Share this article

Shou Arisaka Nov 21, 2025

🔗 Copy Links