I have a batch file that makes a backup of a project folder on my USB stick to a drive on my pc:
@echo off
rem This makes some funky colours
set /a rand1=%random% %% 16
set /a rand2=%random% %% 16
set HEX=0123456789ABCDEF
call set hexcolors=%%HEX:~%rand1%,1%%%%HEX:~%rand2%,1%%
color %hexcolors%
rem This is the xcopy script
echo Initiating copy...
REM copy documents
xcopy "h:\Projects\*.*" e:\Backup\ /s /r /d /y /i
echo %DATE% %TIME% > e:\Backup\xcopy.log
echo Backup Complete
echo Initiating exit...
timeout /t 3
I want this batch file to run every time my USB stick is inserted. I found on the internet that event 2003 and 4688 are triggered when a usb external disk is plugged in.
However when I scheduled a task to run the program 'backup.bat' from '\' on event 2003 and again with 4688 - on inserting a USB stick, the batch file doesn't run. I think this is something wrong with the event trigger as when i run the task in task scheduler it runs the batch file.