派对迟到了 5 年。这是我使用上面最初来自https://gallery.technet.microsoft.com/scriptcenter/ccae4d09-1bee-4f10-8c8c-176a53a65238的脚本编写的一个方便的脚本
我经常插入和拔出 USB 驱动器,并且我喜欢将一些设备“永久”分配给特定的驱动器号。将此代码保存在文本文件中并将其重命名为:ChangeDriveLetter.vbs
将文件放在计算机上的某个位置,然后在桌面或您想要的任何地方创建一个快捷方式。然后右键单击该快捷方式并指定您想要在任何时候更改一两个驱动器号时用来打开它的键盘快捷方式。
这适用于 Windows 10
' Elevate the script to run As Administrator
If Not WScript.Arguments.Named.Exists("elevate") Then
CreateObject("Shell.Application").ShellExecute WScript.FullName _
, """" & WScript.ScriptFullName & """ /elevate", "", "runas", 1
WScript.Quit
End If
' Ask the user which drive to change, and what to change it to.
Sub subAskUser()
strSourceDrive = InputBox("What Drive to Reassign","Enter the drive letter to reassign:","D")
If ((strSourceDrive = vbCancel) Or (strSourceDrive = "") Or IsEmpty(strSourceDrive)) Then
WScript.Quit
End If
strTargetDrive = InputBox("What Letter to Assign","Enter the new drive letter:","Q")
If ((strTargetDrive = vbCancel) Or (strTargetDrive = "") Or IsEmpty(strTargetDrive)) Then
WScript.Quit
End If
'If The letters are present and the user did not cancel, then call the Subroutine to change the letters
subChangeLetter strSourceDrive, strTargetDrive
End Sub
subAskUser()
Sub subChangeLetter(strSourceDrive, strTargetDrive)
'Check that the C: drive is not the letter that the user is trying to change from or to.
If ((strSourceDrive <> "C") And (strSourceDrive <> "c") And (strTargetDrive <> "C") And (strTargetDrive <> "c")) Then
'Uncomment the next lines to see the values entered from the InputBox
'MsgBox strSourceDrive
'MsgBox strTargetDrive
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colVolumes = objWMIService.ExecQuery _
("Select * from Win32_Volume Where Name = '"& UCase(strSourceDrive) & ":\\'")
For Each objVolume in colVolumes
objVolume.DriveLetter = UCase( strTargetDrive) & ":"
objVolume.Put_
Next
Else
MsgBox "Ah, ah, ah! You can't change the C: drive, dude!",16
End If
End Sub
strGoAgain = MsgBox("Change another drive letter?",4)
If strGoAgain = vbYes Then
subAskUser()
End If
WScript.Quit