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

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

我可以使用以下命令列出文件夹中的所有文件: 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.

我是否遗漏了某个开关,或者是否需要使用其他命令?

答案1

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.

相关内容