My problem is similar to Automatically copy files to USB drive when connected.

However, the path of source of the file, which is the desktop, isn't static, so I want the solution to be able to automatically detect the path of the desktop of the current user, because I want to use the USB drive on too many PCs and and I can't select the desktop or specify the path manually.

Any suggestions?

  • Perhaps a portable sync program installed on the USB drive? But I think you're aiming a little high here, interesting though! +1 – Ivo Flipse Oct 29 '09 at 12:09

You want to use %HOMEPATH%\Desktop as your source path. I believe that is correct for XP and up.

  • Another question, please. How can I make the destination path contains the time-date, so files from different PCs don't mix up? – Moayad Mardini Oct 29 '09 at 12:20

You can use %USERPROFILE%\Desktop as the path. Best of all is that this will work with the XCOPY solution, as the batch file will evaluate the environment variables.

  • What is the advantage of using %USERPROFILE%\Desktop over %HOMEPATH%\Desktop? Or are they the same thing? Thanks +1 – Moayad Mardini Oct 29 '09 at 12:17
  • 1
    Some applications may not allow %HOMEPATH% as it starts with a backslash when they expect a drive letter instead. %USERPROFILE% starts with C:\. Both will be fine if using XCOPY though as cmd will evaluate a backslash as the root of the drive. – John T Oct 29 '09 at 12:27

Depending on Internet access/Permissions etc. have you considered using Dropbox? Cloud file storage that seamlessly integrates with Explorer/Finder and syncs files across all systems. Needs a small client install, but otherwise it's a great way to keep multiple systems up to date.

You can also install a portable version of the client called DropboxPortable onto a USB thumbstick and sync files across all accounts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.