Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

7 Answers 7

up vote 14 down vote accepted

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.

share|improve this answer
    
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 5 '09 at 3:46
    
But then you don't know what drive letter got mapped, for the purpose of the rest of the script. –  tomfanning Aug 5 '09 at 8: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. serverfault.com/questions/62578/… –  Chris Magnuson Sep 6 '09 at 23:18

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

share|improve this answer
1  
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 5 '09 at 2:52
    
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 5 '09 at 8:21
    
Actually you might be able to use \\someserver\share...you just need the reg hack to do it :-) –  Bart Silverstrim Aug 5 '09 at 14:31

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

share|improve this answer

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.

share|improve this answer

Wouldn't the junction command work here?

share|improve this answer
    
Don't think so, junction only works for local directories. –  Berzemus Aug 5 '09 at 8: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 5 '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 5 '09 at 11:55

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

There's more background here and here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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