1
0 Comments

I am trying to set up a scheduled task in Windows that automatically copies the contents of a USB drive to a specific folder each time the drive is inserted. I am currently tracking event 2003 (usb drive mount) to obtain the drive’s ID, but I am unsure of how to determine the drive letter that the drive is mounted on.

Here is an example of the script that I would like to use for the task:

@xcopy /E /C /Q /H /Y %%sourcedrive%%\ %systemdrive%\usb_backups%%UUID%%%%date%%\

However, I am uncertain of how to set the variables %%sourcedrive%% and %%UUID%% in this script.

Askify Moderator Edited question May 4, 2023