如何在Windows Powershell中使用cd命令来更改我正在工作的驱动器


20

我读了这个答案,但不适用于Windows PowerShell。如何更换驱动器?

编辑:
请忽略此问题。我试图将驱动器从C:更改为D:。它不起作用的原因是我的计算机上没有D:。一个非常愚蠢的错误。



1
@Excellll不是,您链接到的问题是关于本机外壳(cmd),而不是PowerShell。
Ohad Schneider

顺便说一句,您应该另存为* .ps1文件以在PowerShell中运行...即Set-Location C:\ Folder
CZahrobsky '16

Answers:


35

PowerShell将使用CD解析完全路径。

在DOS中,您必须在/ d中更改驱动器:

cd /d H:\Folder

使用PowerShell,您只需输入完整路径即可:

cd H:\Folder

0

与DOS shell“ cd dir ”相同


cd dir如果dir在另一个驱动器上将无法工作。
马提亚斯·布劳恩

使用/ d开关
Ben Lavender

当然,那是我从Austin T French的答案中收集的。但是/d(至少对我来说)必须添加一点也不明显,这意味着信息应该是答案的一部分。换句话说:cd dircd /d dir
Matthias Braun
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.