如何从 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
How to change drive letter from command prompt or powershell in windows
提问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 $old
and $new
does 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。