Solved Running Batch files from a flash drive

November 18, 2011 at 09:42:55
Specs: Windows 7
I have a batch file on my flash drive that contains the following code:

CD C:\Users\%USERNAME%\Desktop\school
COPY *.* Backup\%USERNAME%

All this is supposed to do is copy a file from my desktop and put it on my flash drive.
But the problem i keep having is that it just copies all the files that are in the same folder of the batch file, and copies them into the directory it made.

Is there a way to fix this?

i know i could just drag the file from the desktop onto the flash drive (and i do). But this is mostly a test. once i get it figured out i will apply it to my main project.

See More: Running Batch files from a flash drive

Report •

November 18, 2011 at 11:19:40
COPY "%UserProfile%\Desktop\school\*.*" Backup\%USERNAME%

How To Ask Questions The Smart Way

Report •

November 18, 2011 at 14:45:22
thank you Razor this is working pretty well.
But there is one more thing. It copies the files just fine but, it doesn't copy the sub-directories. how would i set it to copy all the sub-directories (including the hidden folders).

Report •

November 18, 2011 at 15:02:48
✔ Best Answer

Report •

Related Solutions

November 18, 2011 at 15:37:54
ooh this is brilliant reading material i will let you know what i find out and what works thanks dude

Report •

November 21, 2011 at 11:04:07
Alright I've got it figured out thanks to you Razor. I read through the Xcopy page and found out that all i needed was to add " /s /e /h". so in the end it looked like this:

COPY "%UserProfile%\Desktop\school\*.*" Backup\%USERNAME% \s \e \h

Report •

Ask Question