C:\> cd \\somewhere
CMD does not support UNC paths as current directories.

What I usually do to get around this is to map that directory to a network drive and then I could easily access it from the command prompt.

But is there an easier way on how to get around this?

  • 14
    which windows do you use? If it's Windows 7, you've powershell preinstalled on your system. Powershell supports unc-paths and cmd-commands (with few exceptions). – wullxz May 13 '11 at 11:27
  • You can always browse to the unc path through run. – Supercereal May 13 '11 at 11:45
  • 1
    @wullxz: cheers, I didn't know you could browse UNC paths with PowerShell. @kyle: That's actually a valid answer according to my question :) But I want to access it from a command line environment. Will modify my question to make this more clear. – Andreas Grech May 13 '11 at 12:09
  • If your problem is that you need to work just from the command line, you can map the network drive with the 'net' command: net use x: \\computer name\share name – Al Crowley May 13 '11 at 12:11
  • 1
    @Aleister Crowley: Yes I know, but I'm asking if there's an easier way that doesn't involve mapping a network drive. – Andreas Grech May 13 '11 at 12:12

If you use pushd and popd instead of cd you won't get that UNC error.

pushd <UNC path> will create a temporary virtual drive and get into it.
popd will delete the temporary drive and get you back to the path you were when you entered pushd.


C:\a\local\path> pushd \\network_host\a\network\path

U:\a\network\path> REM a temporary U: virtual drive has been created

U:\a\network\path> popd

C:\a\local\path> REM the U: drive has been deleted

  • 14
    Using pushd creates a drive mapping to the network share and then changes into a path relative to the share it creates. popd disconnects the share. – Dov Sep 6 '12 at 15:55
  • 2
    This didn't work for me on Windows 10. C:\WINDOWS\system32>pushd \\some\network\path ' ' CMD does not support UNC paths as current directories. – kayleeFrye_onDeck Apr 4 '17 at 2:43
  • 1
    It's just worked for me in Windows 10, how odd. I did pushd \\ServerName\home\dir\dir2. – Diziet May 20 '17 at 14:36
  • 3
    Native and elegant, just a wonder. Works for Windows 10. – WesternGun Jun 22 '17 at 7:55
  • Is there any trick to make it work when the share credentials don't match the machine's user credentials? – Perkins Mar 7 '18 at 0:51

I use Git Bash to do this, since I already have it installed.

enter image description here

As an added bonus:
It also has better colors, let's me use ls, rm, etc., and uses the correct slash for paths. :P

  • You can also use backslashes if you escape them with backslashes: cd \\\\server\\share\\subdirectory – user121391 Jul 27 '16 at 8:56
  • 1
    Also, if you try to use tab completion with computer names, the shell might lock up for some time until the names are resolved. – user121391 Jul 27 '16 at 9:03
  • 1
    it does not work for me – KansaiRobot Nov 6 '18 at 9:46

Kliu's "ContextConsole Shell Extension" (aka Open Command Prompt) says it, "can even open directories from network paths (UNC paths)" (from an Explorer window).


enter image description here

  • 4
    This program is most awesome! – afrazier May 13 '11 at 16:37
  • 1
    i'm shocked by the screenshot, it exist! – LiuYan 刘研 Jun 21 '12 at 11:01
  • remember to open the //drive and not a mapped version. It will fail on mapped. – twobob May 4 '17 at 14:04

I also hit the UNC problem with C:\> cd \\somewhere in a C program. Found this page and learnt about the net command: net use x: \\computer name\share name and used it successfully! Thanks to all who post their experiences for others to learn from. :-)

  • 1
    Yes, but using net use will map that location to a network drive and that is not what I wanted. – Andreas Grech Jan 28 '13 at 12:36
  • 2
    @AndreasGrech, Actually pushd does that too. – Pacerier Jan 24 '15 at 6:48
  • This works well in Far+ConEmu, unlike pushd. – Dzmitry Lahoda Jun 3 '16 at 11:29
  • @Pacerier But pushd automatically selects a drive letter and disconnects the network drive when it’s no longer needed (after popd or exit). – Martin Apr 12 '19 at 15:26

If you're using XP you can have a look at this site https://web.archive.org/web/20150518102450/https://support.microsoft.com/en-us/kb/156276

(In case the link breaks again: Under Software\Microsoft\Command Processor: add a DWORD value called DisableUNCCheck if it doesn’t already exist and set it to 1.)

There is a registry value that you need to add, log out, log in again ... and now your cmd.exe does support UNC-Paths. It seems to me that you still can't cd to the path, but you can use it in other commands like dir, copy ...

An alternative might be using the pushd command, that will let you switch to the share (i guess by assigning it a temporary drive letter) https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/pushd

  • The pages you linked seem like empty pages...... – Pacerier Jan 24 '15 at 6:49
  • The links work here. Have you tried using https? – BigBlackDog Jan 27 '15 at 8:21
  • Seems to still work under windows 10 20H2 – T S Feb 10 at 8:48

imho, the most elegant solution is to use mklink /D to create a symlink for the network path. if you use in a script you'll not have to find out which drive letter has been assigned.

  • The most elegant way to change directories (a read-only operation) is to modify the filesystem?  And where do you create the link?  \Temp?  You might not have write access to the current directory.  And what do you call the link?  What if there’s already a \Temp\somewhere that isn’t already a link to \\somewhere?  What if it’s a file that’s in use?  Etc…  How is this more elegant than pushd? – G-Man Says 'Reinstate Monica' Jan 17 '20 at 3:22

You can use the HttpFileServer application, it' over windows, very light and very easy to configure , it allow you to share a network folder UNC ( \server\share ) with HTTP protocol and the HTTP link can be used in any HTML page


it's amazing

  • 10
    Not very useful to a command line user. – Isaac Rabinovitch Oct 20 '12 at 5:17
  • 1
    I agree that this is an amazing piece of software, but how can it be used to get around the fact that the CMD window app does not handler UNC? – Jay Elston Jan 5 '18 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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