如何从 Windows 中的命令提示符或 powershell 更改驱动器号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32746539/
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-08 19:17:07  来源:igfitidea点击:

How to change drive letter from command prompt or powershell in windows

windowspowershellcommand-promptdiskdrive

提问by ReshmaA

I wants to change my computer disk D:\ to E:\ from command prompt or powershell. Is there any way other than 'diskpart'?

我想从命令提示符或 powershell 将我的计算机磁盘 D:\ 更改为 E:\。除了“diskpart”还有其他方法吗?

回答by nehcsivart

Assuming when you said "computer disk" you do notmean the System/Boot Disk, here is a solution using PowerShell. Note the variables. You can either replace them with the actual Drive Letters, or set them ahead of time.

假设您说的“计算机磁盘”不是指系统/启动磁盘,这里是使用 PowerShell 的解决方案。注意变量。您可以用实际的驱动器号替换它们,也可以提前设置它们。

Get-Partition -DriveLetter $old | Set-Partition -NewDriveLetter $new

Note here that $oldand $newdoes notinclude the :character. So in your particular case (changing from D to E), you can use the following.

这里注意,$old$new没有包括:字符。因此,在您的特定情况下(从 D 更改为 E),您可以使用以下内容。

Get-Partition -DriveLetter D | Set-Partition -NewDriveLetter E

Note also that you will need Admin Rights. So run PowerShell as Admin.

另请注意,您将需要管理员权限。因此,以管理员身份运行 PowerShell。