windows 在 CMD / .bat 中,我可以将 dir 从 C 更改为 D 但不能以其他方式更改?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17420992/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:38:53  来源:igfitidea点击:

In CMD / .bat I can change dir from C to D but not other way around?

windowsbatch-filecmdcd

提问by Andre

Ok so here is a copy-paste of my CMD window

好的,这是我的 CMD 窗口的复制粘贴

C:\Documents and Settings\Developer>cd /d "D:\"
D:\>cd /c "C:\"
The filename, directory name, or volume label syntax is incorrect.
D:\>

when I run cd /d "D:\" in C drive it works fine, but when I run cd /c "C:\" in D drive then I get a error

当我在 C 驱动器中运行 cd /d "D:\" 时它工作正常,但是当我在 D 驱动器中运行 cd /c "C:\" 然后我得到一个错误

So how do I change the Directory back to C drive ??

那么如何将目录更改回 C 盘?

EDIT:

编辑:

Here is simpler "copy-paste" of my CMD window

这是我的 CMD 窗口的更简单的“复制粘贴”

C:\>cd /d "D:\"
D:\>cd /c "C:\"
The filename, directory name, or volume label syntax is incorrect.
D:\>

Doesn't make scene why its not working...

没有说明为什么它不起作用......

回答by Ansgar Wiechers

The parameter is always /d(for "drive"), so you need to do

参数总是/d(对于“驱动器”),所以你需要做

D:\>cd /d C:\

instead of

代替

D:\>cd /c C:\

回答by Magoo

OK, I'll set it as an answer, then...

好的,我将其设置为答案,然后...

How about cd /d "C:\"rather than cd /c"c:\"

怎么样cd /d "C:\"而不是cd /c"c:\"

回答by Andre

cd /d "C:\"

is the answer

是答案

Credit go's to Peter Wright

归功于彼得赖特

回答by Vinod Kumar

You can change dir from c to d with simple command

您可以使用简单的命令将 dir 从 c 更改为 d

C:\> d:

Then you will get

然后你会得到

D:\>

回答by Nyein

To change D:drive to C:drive, type just c::

要更改D:驱动器到C:驱动器,只需键入c:

d:\>c:    
c:\>

To change c:drive to d:drive, d::

要更改c:驱动d:器,请d:

c:\>d:    
d:\>

回答by Endoro

you can't use cd /x x:\for your network drive, the command is always cd /d

你不能cd /x x:\用于你的网络驱动器,命令总是cd /d