Following on from lasts week tip about Robocopy, if you are backing up to a USB drive there is a chance that every time you use the drive (maybe on different machines) under Windows you get a different drive letter.

So if you have a batch file saved on the drive with your finely crafted backup script, it may fail if your drive D:\ is now drive E:\

Enter to the rescue just the variable you need:


Which gives you the path to the file in which the script is being run from,

so something like

robocopy \\my-server\files %~d0\backupfolder /mir

saved as ‘backup.bat’ in the root of your usb drive will work everytime.