Hola a todos, me gustaria saber si es posible y de paso un norte en cuanto a lo siguiente:
tengo un PC con 3 particiones (C:\, D:\, Z:\) las 3 NTFS y en Z es donde guardo mis cosas, pero me gustaria saber si puedo crear un script que le quite automaticamente la letra a la unidad y otro que me la asigne. Ya que seria algo tedioso estar yendo al administrador de discos logicos y desmontar/montar la unidad cada vez que yo vaya a usarla.
MSDN explica una solución a este problema utilizando el proceso "MountVol" ~> http://blogs.msdn.com/b/alejacma/archive/2010/03/17/how-to-change-drive-letters-vbscript.aspx
He modificado un poco el Snippet y he tomado parte del código para añadir el Método que desmonta la unidad (más abajo):
Sub ChangeDriveLetter(SourceDrive, TargetDrive)
Set WSS = WScript.CreateObject("WScript.Shell")
If Not Right(SourceDrive, 1) = ":" Then
SourceDrive = SourceDrive & ":"
End If
If Not Right(TargetDrive, 1) = ":" Then
TargetDrive = TargetDrive & ":"
End If
' Get volume associated to the old drive letter.
Set Exec = WSS.Exec("mountvol.exe " & SourceDrive & " /L")
strVolume = Trim(Exec.StdOut.ReadLine())
while Exec.Status = 0 : WScript.Sleep(100) : Wend
' Unmount the drive.
Set Exec = WSS.Exec("mountvol.exe " & SourceDrive & " /D")
while Exec.Status = 0 : WScript.Sleep(100) : Wend
' Mount the drive on the new drive letter.
Set Exec = WSS.Exec("mountvol.exe " & TargetDrive & " " & strVolume)
while Exec.Status = 0 : WScript.Sleep(100) : Wend
End Sub
Sub UnmountDrive(DriveLetter)
Set WSS = WScript.CreateObject("WScript.Shell")
If Not Right(DriveLetter, 1) = ":" Then
DriveLetter = DriveLetter & ":"
End If
' Unmount the drive.
Set Exec = WSS.Exec("mountvol.exe " & DriveLetter & " /D")
while Exec.Status = 0 : WScript.Sleep(100) : Wend
End Sub
Ejemplos de uso:
ChangeDriveLetter "Z", "X"
UnmountDrive "Z"
Saludos.