Automatic File Sync from USB Key on Windows 7

As usual with most fort peu avouables (if you pardon my French) matters, I shall first explain how I didn’t check out this question for myself, but for one of my relatives who wished to perform automatic file syncs from and to his USB key on Windows 7 running on his iMac (oh my…) That being said, here is the best solution I found for him.

The goal is: when a given USB key is plugged into the computer, synchronize all files in a given folder on the key (for example D:\SyncFolder) with a mirror folder on the local hard drive (for example C:\Users\Me\SyncFolder).

Requirements:

  • Windows 7 with Task Scheduler and Event Viewer installed.
  • SyncToy 2.1, a software from Microsoft.

First, download SyncToy using the link above. Plug your drive in and establish a folder pairing between your two folders, in our example D:\SyncFolder and C:\Users\Me\SyncFolder (for more information, check out this tutorial on folder pairing with SyncToy).

Next, create an event using the Task Scheduler, which is installed by default on Windows 7. You’ll find it in Start Menu → Accessories → System Tools.

  • In the Triggers tab, create a new “On Event” trigger. The USB insertion event is a little hard to find: on my system, it was located in Event Viewer/Applications and Services Logs/Microsoft/Windows/DriverFrameworks-UserMode/Operational. Plug our key in and out once or twice and spot the new events in the log; note the ID of the last one (make sure the description has something to do with the particular USB drive you inserted) and report it in the Task Scheduler.
  • In the Action tab, create a new “Start Program” action. In the Start a Program window, browse to SyncToyCmd.exe (in SyncToy’s install folder). The argument should be "-R PairName" (where “PairName” is, guess, the name you gave to the pairing in SyncToy). Beware, the command line is case sensitive.

Note that this approach has multiple limitations: if the drive letter for you key changes, you’ll have to configure the pairing again, and software re-plugs of USB drives tend to occur quite frequently (every 5 min on my machine). The plus side of this behavior is that your files are synced as well, but it turns into a minus side if you are using a (battery-powered) laptop. In the latter case, you can check the “Start the task only if the computer is on AC power” option in the Conditions tab of your event.

This is the best solution I’ve found for now (given that, for good reasons, autorun.inf files don’t work any more). Most of the help came from this question on superuser.com.

Discussion

Feel free to post a comment by e-mail using the form below. Your e-mail address will not be disclosed.

📝 You can use Markdown with $\LaTeX$ formulas in your comment.

By clicking the button below, you agree to the publication of your comment on this page.

Opens your e-mail client.