Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a remote directory that is shared and mounted to my localhost. I know the remote directory is mounted and shared correctly as I can read, write, execute the file during a normal mouse and click event.

Although, I do need to script something and would like to do this using the Windows cmd executable.

For example, I want to cd/ change directory into the the remote directory and rename the file.

How do I do so in a sample Windows script?

So far, the command line below isn't working for me. I might not be passing this properly in the first place.

C:\>cd \\myremotehost\MY_DIR



CMD does not support UNC paths as current directories

I want to script this and rename myfile to mynewnamefile.

share|improve this question
The error message CMD gives you is very straightforward: "CMD does not support UNC paths". You need to map a drive to it so that CMD doesn't have to know that it's a UNC path. – jcrawfordor Jun 10 '11 at 2:18
Does it have to be with the UNC (\\myremotehost\MY_DIR), or do you care if it is mapped (given a drive letter)? Do you want a workaround? – KCotreau Jun 10 '11 at 2:29
it doesn't matter for the directory name. I was able to mount using a letter. as long as i can make my way to the files. – jdamae Jun 10 '11 at 2:37
Duplicates this ServerFault question. – JdeBP Jun 10 '11 at 10:28
up vote 5 down vote accepted

You need to mount the network location as a network drive before you can use it from the command prompt. Like so:

net use x: \\myremotehost\MY_DIR

Afterwards you should be able to perform whatever operations you want, using the X:\ in place of \myremotehost\MY_DIR. When you are done, you can disconnect the drive with

net use x: /delete
share|improve this answer
You can also map the drive, x: in this case, from My Computer and it will work just the same in your script. – Garrett Jun 10 '11 at 2:23
@Fopedush- got the mount working now. Thank you. I can see the files using ls x: – jdamae Jun 10 '11 at 2:33

Your share is probably mounted as a drive letter. You would most likely want to do something like this:

ren X:\my file myfile

To script it, you could simply put the command into a .cmd file.

share|improve this answer
That assumes that he maps it. Ren does not work with UNC names. – KCotreau Jun 10 '11 at 2:17
It does assume he maps it. He did say it was mounted, which could mean a few things in Windowsland. – Kirk Jun 10 '11 at 2:21
@Kirk- thanks for your input. So far, I do have the mount now, thanks to Fopedush. Its "x:" . Although now I am trying to rename that file and getting The syntax of the command is incorrect. As for the obvious, I can see the files when i do ls x: Thanks! – jdamae Jun 10 '11 at 2:32
found it its ren x:\my file newfile. thanks guys! – jdamae Jun 10 '11 at 2:36
Edited my answer to reflect the correct syntax. – Kirk Jun 10 '11 at 2:42

Based on your comment, then what you want to do is this batch file:



ren filename newfilename

The first command seems to be what you are missing.

Another workaround if you want to use the UNC is this:

xcopy \\server\directory\filename \\server\directory\newfilename

del \\server\directory\filename

The effect is the same.

share|improve this answer

I recommend using 'net use' and map a drive letter and manually unmap it as it works on all versions of Windows.

However, it is good to know that pushd instead of cd will (depending on the version of Windows) map a drive letter for you automatically, but make sure to call popd to unmap the drive letter.

**pushd** \\server\directory\  
ren filename filenamenew  
share|improve this answer

Your Answer


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.