I am attempting to change directories to a file server such as:

cd \\someServer\\someStuff\

However, I get the following error:

CMD does not support UNC paths as current directories

What are my options to navigate to that directory?

  • 720
  • 1
  • 9
  • 13
  • 2
    Related: [Browse an UNC path using Windows CMD without mapping it to a network drive](https://superuser.com/q/282963/2357) from Super User – Cristian Ciupitu Feb 14 '18 at 21:46

13 Answers13


If you're considering scripting it, it's always helpful to learn about the pushd and popd commands. Sometimes you can't be sure what drives letters are already used on the machine that the script will run on and you simply need to take the next available drive letter. Since net use will require you to specify the drive, you can simply use pushd \\server\folder and then popd when you're finished.

  • 24,484
  • 8
  • 79
  • 100
  • 6,451
  • 2
  • 42
  • 63
  • If you specify '*' instead of a drive letter net use will use the first available drive checking from Z-A. so 'net use * \\server\share' with no Z: drive mapped would map \\server\share to Z: – Zypher Aug 05 '09 at 03:46
  • But then you don't know what drive letter got mapped, for the purpose of the rest of the script. – tomfanning Aug 05 '09 at 08:41
  • @tomfanning You can find the drive letter by using this (wmic logicaldisk get caption,providername,drivetype,volumename) from the command prompt and then parse the output looking for your \\servername\sharename. http://serverfault.com/questions/62578/how-to-get-a-list-of-drive-letters-on-a-system-through-a-windows-shell-bat-cmd – Chris Magnuson Sep 06 '09 at 23:18
  • 1
    @pk. What if the script crashed before it runs your `popd`? – Pacerier Jan 24 '15 at 06:41
  • @Pacerier The drive letter remains mapped until you log off or unmap it yourself. Do it enough times (~ 25 X) and you will see "CMD does not support...", which is misleading. You may be able to use popd, if the same instance of cmd is available. Note: CMD files run under the same instance as the command line. This why environment changes, such as the current directory or pushd can be done in a batch file. By contrast, Unix forks a new process to run script files. Thus cd has no effect on the command-line environment. – Andrew Dennison Oct 28 '20 at 13:16

Or you could switch your shell to PowerShell. It has complete support for UNC paths.

Peter Mortensen
  • 2,318
  • 5
  • 23
  • 24
  • 1,192
  • 3
  • 11
  • 19
  • 1
    Except when explorer.exe has a handle on the file you're trying to delete. Even with explorer window closed, I think the PS FileSystem provider (assuming it's a provider) probably uses explorer.exe under the hood. or are you saying there is a way to use UNC without the provider? – JohnZaj Jun 12 '18 at 04:30

You could use net use to map a network drive to a UNC path and then browse to the mapped drive.

  • 133
  • 4
Sam Cogan
  • 38,736
  • 6
  • 78
  • 114
  • 3
    True this is the only way to do it from the command line, but be wary of using this for anything except throw-away commands (i.e. things you only do once) because otherwise you run into issues with the drive not being mapped, or being mapped but not connected, and multiple usernames :( – Mark Henderson Aug 05 '09 at 02:52
  • 1
    You can't change to this directory, but you still can use it in commands: dir \\someserver\stuff call \\someserver\stuff\whatever.bat – Benoit Aug 05 '09 at 08:21
  • 1
    Actually you might be able to use \\someserver\share...you just need the reg hack to do it :-) – Bart Silverstrim Aug 05 '09 at 14:31
  • @BartSilverstrim, How? – Pacerier Jan 24 '15 at 06:42

This worked for me in Win8x64:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor]

You should be able to do this in HKCU as well, just make sure you log off and back on again.

  • 131
  • 3

Pushd Works, but ...

I have been using

pushd "%~dp0\"

at the start of cmd files for longer than I can remember, always with a complementary


at the end of the file. Until recently this was working, when:

  1. My script was pausing and I was using ^C to exit.
  2. I did this about 24 times over several days of testing on a remote desktop.

Then I got the vague error, if not completely misleading error:

CMD does not support UNC paths as current directories.

Finally, I thought to try


To my surprise, I had used all of the drive letters up. After I did


I was happy again knowing I had not lost my mind.

Here is my standard cmd prolog:

SETLOCAL EnableExtensions
rem pushd handles Windows dumbness when the command directory is a UNC
rem and we want to use it as the current directory. e.g. click launch a cmd file on the network.
pushd "%~dp0\"

Slightly longer explanation of pushd here: http://shortfastcode.blogspot.com/2010/05/how-to-deal-with-cmd-does-not-support.html

  • 121
  • 3

Instead of

cd \\server_name\folder_name


pushd \\server_name\folder_name

..EXE path here..


Below code completely worked for me, see the example

@echo off
echo "Email payment to prod payment sync program started"

pushd \\Server_name\it\0a. IT Projects\XYZ Project\Report Builds\Emailpayment to prod payment sync build

"\\Server_name\it\0a. IT Projects\XYZ Project\Report Builds\Emailpayment to prod payment sync build\xyz.exe" 

pushd \\Server_name\it\0a. IT Projects\XYZ Project\Report Builds\Daily Invoice report build

"\\Server_name\it\0a. IT Projects\XYZ Project\Report Builds\Daily Invoice report build\XYZ1.exe" %-5

echo "Daily invoice report program ended"
  • 6,725
  • 7
  • 22
  • 32

As well as explicitly mapping a drive so that cmd can cope, which might be needed by other utilities too, you could also try an alternative command shell like PowerShell.

David Spillett
  • 22,754
  • 45
  • 67

as per @pk use pushd & popd, here is an example.

use pushd to create a temporary virtual drive and after done do a popd to delete the temporary virtual drive

REM Confirm which Folder structure
set /p location="Delete files for which QA environment: (P)retoria, (C)ape, (L)uanda or (Q)uit? (C/L/P/Q)"
REM  I option allows for upper and lower case
if /I "%location%"=="C" set folder="\\Tfwcqa\tfwcqa\EORDERS"
if /I "%location%"=="L" set folder="\\Tfluaqa\tfluaqa\EORDERS"
if /I "%location%"=="P" set folder="\\Tfptaqa\tfptaqa\EORDERS"
if /I "%location%"=="Q" goto endBatch

REM you can not cd to a network drive so we use pushd to create a temporary virtual drive
REM cd /d %folder%
pushd %folder%


REM popd deletes the temporary virtual drive
  • 171
  • 2
  • 9

This works for me:

set NetworkFolder=\\server\folder
dir %NetworkFolder%\subfolder

Wouldn't the junction command work here?

Bart Silverstrim
  • 31,172
  • 9
  • 67
  • 87
  • 1
    Don't think so, junction only works for local directories. – Berzemus Aug 05 '09 at 08:07
  • Does it work? From the Wikipedia article: "Junction points can only link to directories on a local volume; junction points to remote shares are unsupported." – Peter Mortensen Aug 05 '09 at 11:41
  • @#%!# you're right. I was thinking it was like a mount command, forgot I had this problem when I looked into it two years ago. *sigh* Sorry... – Bart Silverstrim Aug 05 '09 at 11:55

Hey, here's one to try...

Go to this page and search for "allow unc path"...will that work?

There's more background here and here

Bart Silverstrim
  • 31,172
  • 9
  • 67
  • 87

You have an extra backslash in your UNC. The double backslash BEFORE "someServer" IS appropriate. The double backslash before "someStuff" should be a single backslash, no?

So, try