Let's say there is a file \\server-42\tmp\dir\test.txt. When my plugin tries to execute this command via system() it triggers an error:

cd "\\server-42\tmp\dir" && git ls-files --error-unmatch --full-name test.txt

The error is E484: Can't open file C:\Users\foo\AppData\Local\Temp\blah.tmp.

The directory is produced by shellescape(fnamemodify(filepath, ':h'), where filepath is the full path to file. The file is produced by shellescape(fnamemodify(filepath, ':t').

How can I get this to work?

Many thanks in advance!

  • 1
    that will be hardly possible, since I believe Windows cmd does not support UNC paths at all (Try cd \\server-42\temp\dir) You would have to map the network drive to drive letter and work with that I believe Commented Feb 14, 2018 at 10:57
  • Windows supports \\hostname\path (for almost as long as I can remember...I'm dating myself)...they call it a 'network path', though. :P I haven't tried to use them in Vim, though.
    – B Layer
    Commented Feb 14, 2018 at 11:13
  • 1
    Windows does, but not the command line subsystem of Windows. However, it seems like you might be able to use pushd and popd instead Commented Feb 14, 2018 at 12:04
  • @ChristianBrabandt My bad. My eyes skipped right over 'cmd'.
    – B Layer
    Commented Feb 16, 2018 at 1:50
  • @ChristianBrabandt Good to know that cmd does not support UNC paths at all. Also, pushd seems to work – thanks! I'll be happy to accept if you add it as an answer. Commented Feb 16, 2018 at 11:44

1 Answer 1


The problem you are encountering is, that the commandline subsystem on Windows does not support UNC paths. (Try running cmd.com and then cd \\server\path\to\dir and notice the error message CMD does not support UNC paths as current directories.)

That leaves you with mapping the path to a temporary drive letter using net use or instead of using cd use pushd instead, which basically maps your path to a temporary drive letter so you'll be able to access that file afterwards easily.

Using pushd will temporarily create a drive mapping to the network share and then change into a path relative to it. popd then will disconnects the share and return to your previous current directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.