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?
Solution 1:
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 <DIR> .
12/16/2015 11:18 AM <DIR> ..
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 <DIR> .
12/16/2015 11:18 AM <DIR> ..
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.