Monday, 31 December 2018

cmd.exe - Change working directory to network share


I can list all files in a folder with: dir \\aenw08v401\FOLDER\I001\*


However, when I execute cd \\aenw08v401\FOLDER\I001, the current working directory won't change at all.


This is what I see when I execute net view \\aenw08v401:


Shared resources at \\aenw08v401
Share name Type Used as Comment

-----------------------------------
FOLDER Disk
The command completed successfully.

Is there a switch I am missing, or do I need to use a different command?



Answer



The Windows command prompt cmd does not support UNC paths as current directories.


C:\Users\User1>cd \\myServer\myShare
CMD does not support UNC paths as current directories.

Solution: Use pushd.


C:\Users\User1>pushd \\myServer\myShare

Z:\>dir
Volume in drive Z is MYDRIVE
Volume Serial Number is 1234-5678

Directory of Z:\

12/16/2015 11:18 AM
.
12/16/2015 11:18 AM
..
0 File(s) 0 bytes
2 Dir(s) 120,609,575,936 bytes free

Z:\>popd

C:\Users\User1>

Alternate Solution: Map the UNC path to a drive letter.


C:\Users\User1>net use Y: \\myServer\myShare 
The command completed successfully.

C:\Users\User1>Y:

Y:\>dir
Volume in drive Y is MYDRIVE
Volume Serial Number is 1234-5678

Directory of Y:\

12/16/2015 11:18 AM
.
12/16/2015 11:18 AM
..
0 File(s) 0 bytes
2 Dir(s) 120,609,575,936 bytes free

Y:\>C:

C:\Users\User1>net use /delete Y:
Y: was deleted successfully.

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...