AutoMountRemoveUSB Drive
AutoMountRemoveUSB Drive
GetMountvol.VBS
strDrive = InputBox("Please enter your USB drive letter"+vbCr+" example: L:", "USB
Drive Letter", "L:")
Dim f, f1
Set f=CreateObject("Scripting.FileSystemObject")
If f.DriveExists(strDrive) Then
dim oShell
Set oShell = CreateObject("WScript.Shell")
return = oShell.Run("cmd /c mountvol "+strDrive+" /L > mountvol.txt", 0, true)
Set f1 = f.OpenTextFile("mountvol.txt" ,8 , True)
f1.WriteLine(strDrive)
else
WScript.echo "Invalid Drive"
End If
WScript.quit
MountUSBdisk.VBS
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("mountvol.txt")
strGUID = trim(f.ReadLine)
strDrive = f.ReadLine
f.Close
Set fso= Nothing
intTimeout = 5 'Number of seconds to wait
strMessage = "USB disk drive mounted as "+strDrive
strTitle = "RescanUSBdisk"
Dim oShell
Set oShell = CreateObject("WScript.Shell")
oShell.Run "mountvol "+strDrive+" "+strGUID
intResult = oShell.Popup(strMessage, intTimeout, strTitle)
Wscript.Sleep 10*1000
WScript.quit
RemoveUSBdisk.vbs
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("mountvol.txt")
strGUID = trim(f.ReadLine)
strDrive = f.ReadLine
f.Close
Set fso= Nothing
intTimeout = 5 'Number of seconds to wait
strMessage = "USB disk device "+strDrive+" removed"
strTitle = "RemoveUSBdisk"
Dim oShell
Set oShell = CreateObject("WScript.Shell")
oShell.Run "mountvol "+strDrive+" /d"
intResult = oShell.Popup(strMessage, intTimeout, strTitle)
Wscript.Sleep 10*1000
WScript.quit
When saving the above scripts in Notepad, please ensure that they are saved as .VBS files, not as
default .TXT files. The three VBS files should be in the same folder.
Note: You can test the .VBS scripts by running these in an Administrator Command prompt window
using the full file name, i.e. GetMountvol.vbs / RemoveUSBdisk.vbs / MountUSBdisk.vbs
Important:
GetMountvol.vbs needs to be run in order to create a further ‘mountvol.txt’ file which is then used by
the two other VBS scripts to find the correct USB drive letter and Volume GUID information.
This script will prompt for the USB drive letter in the normal L: format.
\\?\Volume{18000000-0000-0000-0000-100000000000}\
L:
2) Create your Acronis backup task which will write to your external USB drive.
Note: the task configuration needs to be completed while the USB drive is connected as otherwise
settings will be lost should the drive disconnect before these are completed.
3) Select the backup task Options, then open the Advanced settings page, then select Pre/Post
Commands then click on ‘Use custom commands’
Click on EDIT for the Post-Command and navigate to where the RemoveUSBdisk.vbs script is stored
and select this script. Use the option to Test the command and confirm that the script runs successfully.
Click on EDIT for the Pre-Command and navigate to where the MountUSBdisk.VBS script is stored
and select this script. Use the option to Test the command and confirm that the script runs successfully.
Click on OK when the above is done, then run the backup task.