Hi all

I am new to all this coding and after a bit of googling I came up with two scripts to backup my user profile folder (with a couple of folder exceptions) to a hard drive when it is inserted. When the USB drive is inserted windows creates an entry in the system log with event ID 98. Based on this I have a scheduled task which calls a VB script to check for the volume label iof my HDD then launch a batch file which runs robocopy.

I would like to merge all this into one VB script and instead of being prompted by the batch script in a DOS window for the yes/no have a nice GUI popup via the VB Script.

Can anyone help me translate the following into one script as above

my VB script

set fso=CreateObject("Scripting.FileSystemObject")
set WshShell=CreateObject("WScript.Shell")


Function getDriveLetterFromVolumeName()
Dim volumes, volume

' Unless we found a matching volume, an empty string will be the returned value
getDriveLetterFromVolumeName=""

' Ask WMI for the list of volumes with the requested label
Set volumes = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") _
.ExecQuery("SELECT DriveLetter FROM Win32_Volume WHERE Label='ASA'")

' If exist an matching volume, get its drive letter
If volumes.Count > 0 Then
For Each volume In volumes
getDriveLetterFromVolumeName = volume.DriveLetter
Exit For
Next
End If

End Function

usbdrive=getDriveLetterFromVolumeName
batchfile="hdd_backup.bat"

do
if drivechk(usbdrive)<>"" then exit do
wscript.sleep (7200000)
loop

WshShell.run "cmd /c" & batchfile & " " & usbdrive

function drivechk(d)
on error resume next
set chk=fso.getDrive(d)
if err.number then err.clear:exit function
drivechk=chk.path
end function


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
and my batch script

@echo OFF

set /p ask=Do you want to backup to %1? (y/n)
if %ask%==y robocopy c:\users\username %1\robocopy /MIR /XA:SH /XF c:\users\username\NTUSER.DAT /XD c:\users\username\AppData /XD "c:\Users\username\Application Data" /XD c:\Users\username\Cookies /NFL /XJ



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Thanks in advance