2014-01-21 15:02:58 +0000 2014-01-21 15:02:58 +0000
8
8
Advertisement

通过脚本/软件安装和拆卸硬盘驱动器

Advertisement

有沒有辦法在 Windows 8.1 中透過腳本或簡單的工具軟體來掛載和卸載連接的硬碟?

基本上,我在ThinkPad的Ultrarabay插槽里有一个硬盘(而不是DVD驱动器)。当启动系统时,这个硬盘驱动器会自动被挂载,并且对我来说是可见的。使用任务栏中的图标,我可以卸载它。不幸的是,只有当我重新启动系统时,它才会重新可用。

所以我想问一下,有没有什么命令行脚本可以让我在不用重启的情况下,用另一个脚本来卸载硬盘并重新挂载?

这样我就可以在启动后调用unmount-script,这样硬盘就不会一直运行,只有当我需要它的一些东西时,我才会调用mount-script,然后就可以访问文件。

如果有人有什么办法解决这个问题,那就太好了! 谢谢大家

Advertisement
Advertisement

答案 (4)

8
8
8
2014-01-22 06:22:36 +0000

_DISCLAIMER: 你要对自己的行为负责。

在做了一些研究之后,我发现了 This Instructable,详细介绍了如何使用Windows命令 Mountvol 来挂载和卸载驱动器。

教程

1.首先,以管理员身份打开命令提示符。 2. 运行命令mountvol,并注意你要挂载/卸载的驱动器字母上方的卷名(例如`\?\Volume{########-####-####-####-############}_DISCLAIMER: 你要对自己的行为负责。

在做了一些研究之后,我发现了[ This ]0x3& Instructable,详细介绍了如何使用Windows命令[ Mountvol ]0x3&来挂载和卸载驱动器。

教程

1.首先,以管理员身份打开命令提示符。 2. 运行命令mountvol,并注意你要挂载/卸载的驱动器字母上方的卷名(例如 )

  1. 要卸载驱动器,请键入 mountvol [DriveLetter] /p。请确保将"[DriveLetter]“替换为指定给您要卸载的驱动器的字母,例如,G:)

  2. 要掛載磁碟機,請輸入 mountvol [DriveLetter] [VolumeName]。确保将”[DriveLetter]“替换为您希望挂载驱动器的字母,例如,G:,并将”[VolumeName]“替换为您在步骤 2 中记录的卷名。

批处理脚本

这是两个简单的批处理脚本的例子,你可以用它来挂载和卸载你选择的驱动器:

为了使批处理文件工作,你需要用管理权限来运行它们,否则批处理文件将返回一个Access Denied错误。

Unmounting:

@echo off

REM Be sure to change this to the drive you want to unmount! 
set drive=G:

echo Unmounting Drive...
mountvol %drive% /p
echo Drive Unmounted!

pause
exit

Mounting:

@echo off

REM Be sure to change this to the drive letter you want to mount the drive to!
set drive=G

REM Be sure to change this to the Volume Name of the drive you want to mount!
set volume=\?\Volume{ae101d9f-7653-11e3-be83-8056f23387a6}\

:start
echo Mounting Drive...
mountvol %drive%: %volume%
echo Drive Mounted!

pause
exit

在运行批处理文件之前,请确保修改顶部的批处理文件,以确保你正在安装/卸载正确的驱动器。

不要使用/D,因为它只会删除驱动器编号分配,请使用/p。从挂载卷/?: /p Removes the volume mount point from the specified directory, dismounts the volume, and makes the volume not mountable. You can make the volume mountable again by creating a volume mount point.

2
2
2
2014-12-21 07:01:55 +0000

试试这个,我不知道这是不是你想要的。启动diskpart(在start中搜索 “diskpart "或打开cmd窗口输入diskpart。你需要有管理权限才能运行 diskpart)

1.在 diskpart 中输入 "list volume",记下卷号和卷名 2. 输入 "select volume [drive letter(或drive number)],按回车键,例如:"select volume G "或 "select volume G"。输入 "select volume G "或 "select volume 5” 3.键入 “remove letter [volume lETTER]"例如remove letter G

DONE!

要挂载卷,请尝试以下步骤,

1.按照第一和第二步操作。注意,你只能看到卷号和其他细节,不能看到卷号。 2.输入 "assign letter [volume letter]",这里将[volume letter]替换为任何你想分配给该卷的字母。

1
Advertisement
1
1
2014-11-19 12:55:07 +0000
Advertisement

您可以使用 diskpart 命令行工具。它有 “自己 "的命令行,可以接受diskpart命令。

这里有一篇关于这个工具的文章。链接到technet.microsoft.com

你必须: - 运行 diskpart.exe。

  • 运行 diskpart.exe (Windows Vista/7/8 系统自带,也许有些更老的系统也是如此)
  • 使用 select disk n 命令选择磁盘 (其中 n 是磁盘号)
  • 使用 select partition n 命令选择分区 (其中 n 是分区号)
  • 使用下面描述的参数运行 assign 命令

assign [{letter=d|mount=path}] [noerr]

为焦点卷分配一个驱动器编号或挂载点。如果没有指定驱动器代号或挂载点,则分配下一个可用的驱动器代号。如果指定的驱动器代号或挂载点已经在使用中,则会产生一个错误。

通过使用 assign 命令,您可以更改与可移动驱动器关联的驱动器代号。您不能为系统卷、启动卷或包含分页文件的卷指定驱动器代号。您不能为 OEM 分区或除基本数据分区以外的任何 GPT 分区指定驱动器代号。

letter=d 指定您打算分配给卷的驱动器代号。

mount=path 指定您打算分配给卷的挂载点路径。

您也可以使用list disklist partitionlist volume来查找您的磁盘/分区/卷号。

**小心你在用这个工具做什么。它可能被用来格式化驱动器。

1
1
1
2014-01-22 08:31:34 +0000

在 powershell 中,我们可以通过 WMI 方法进行挂载/卸载。

Get-WmiObject -class Win32_Volume | where-object {$_.DeviceID -Like "\?\Volume{########-####-####-####-############}\"} | foreach-object -process {$_.AddMountPoint("X:")}

要卸载,可以这样做。

Get-WmiObject -class Win32_Volume | where-object {$_.DeviceID -Like "\?\Volume{########-####-####-####-############}\"} | foreach-object -process {$_.Dismount()}

这里是如何从 powershell 找到 GUID。不要忘记编辑样本。

Get-WmiObject -class Win32_Volume | Select-Object DeviceID,DriveLetter
Advertisement

相关问题

3
19
10
28
3
Advertisement
Advertisement