将工作目录更改为网络共享


23

我可以使用以下命令列出文件夹中的所有文件: dir \\aenw08v401\FOLDER\I001\*

但是,当我执行时cd \\aenw08v401\FOLDER\I001,当前的工作目录根本不会改变。

这是我执行时看到的net view \\aenw08v401

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

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

我是否缺少开关,还是需要使用其他命令?


Answers:


29

Windows命令提示符cmd不支持将UNC路径用作当前目录。

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

解决方案:使用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>

替代解决方案:将UNC路径映射到驱动器号。

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.

2
推送的解决方案对我来说非常理想,尽管最终psexec对我
而言

1
或在可行的地方使用PowerShell cd \\Server\path
富兰克林·于
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.