i have looked on the forums and found a few different USB backup utilities but not quite what i wanted so i have adapted one of them into this script
Code:
#Noenv
#Persistent
backup=%A_Desktop%\USB_Backup
FileCreateDir,%backup%
DriveGET, USB, List, REMOVABLE
settimer, check, 1000
return
check:
ret := scan4NewDrivesDrives(USB)
If (!ret)
{
;nothing here
}
else
{
msgbox Found New device! : %ret% ;here you can add code, wich should be executet if a NewDrives USB Device is plugged in.
DriveGet,SN, Serial, %ret%:
USB_DIR = %backup%\%SN%
MsgBox,4, USB Backup, Do You want %ret% to be backed up
IfMsgBox,YES
{
FileCreateDir,%USB_DIR%
FileCopyDir, %ret%:, %USB_DIR%,1
if Errorlevel <> 0
{
FileCopy, %ret%:, %USB_DIR%,1
Failed:=ErrorLevel
Loop, %ret%:\*.*,2
{
FileCopyDir, %A_LoopFileFullPath%, %USB_DIR%\%A_LoopFileName%,1
Failed+=ErrorLevel
}
}
Msgbox, , USB Backup, %ret% backed up to %USB_DIR%
}
}
return
scan4NewDrivesDrives(byref olddrives)
{
DriveGET, NewDrives, List, REMOVABLE
Loop, parse, NewDrives
{
if InStr(olddrives, a_loopfield)
{
;still here
continue
}
else
{
;found New device!
olddrives := NewDrives ;update
return, % a_loopfield
}
olddrives := NewDrives ;update
return, 0 ;no New devices found.
}
}
PROBLEM: Code doesn't register flashdrive being removed
how do i do this