Step 3: Make the file for copy of documents to drive

This is the heart of the flash drive copy I am not going to go through every line of code here but if you have questions just ask or use Google, I will however touch on the main points of the code.
Like the last step make sure you use word to make this file save it as file.bat and all files not a word file just like in the picture.
Code follows

@echo off
:: variables
SET odrive=%odrive:~0,2%
set backupcmd=xcopy /s /c /d /e /h /i /r /y
echo off
%backupcmd% "%USERPROFILE%\pictures" "%drive%\all\My pics"
%backupcmd% "%USERPROFILE%\Favorites" "%drive%\all\Favorites"
%backupcmd% "%USERPROFILE%\videos" "%drive%\all\vids"
@echo off

what this code does
looks for what drive letter the flash drive is and sets it
starts xcopy
looks for current users pictures, favorites, and videos folder then copy's them to the found flash drive in folders my pics, favorites, and vids
clears screen and shuts down window

now the fun part of this code it can be changed to suit your needs say you need to copy say music folder the code would change to %backupcmd% "%USERPROFILE%\music" "%drive%\all\music"

very clever huh
<p>Am having issues am using a windows 8 and i followed the instructions one after the other but its not working </p>
<p>How to Setup USB Flash drive to install Windows</p><p><a href="http://www.baatkar.com/2015/09/how-to-setup-usb-flash-drive-to-install.html" rel="nofollow">http://www.baatkar.com/2015/09/how-to-setup-usb-flash-drive-to-install.html</a></p><p>Thanksssss</p>
<p>How can I make it to copy a flash drive? Let say someone has a flash drive plugged in and I put mine in and I can copy them without them knowing? I copied everything above and it works but i also want to be able to copy there flash drive help!!</p>
I made all the file as described but its is not working my windows is 8.1 pro. Plz. Solve my problem as fast as can. After i click on file.bat command prompt pop up and copying start . Solve my problem. Thanks
<p>my only question is how do you reverse the processs? How do you make the computer copy the USB files onto the computer? it seems that would be better for trolling</p>
<p>In the file.bat this code is in there to copy files from the PC.</p><p>%backupcmd% &quot;%USERPROFILE%\pictures&quot; &quot;%drive%\all\My pics&quot;</p><p>So if you switched the two codes in quotes it'll copy files from the USB. Like So.</p><p>%backupcmd% &quot;%drive%\all\My pics&quot; &quot;%USERPROFILE%\pictures&quot;</p>
ok so this is what i want to be able to do can you give me an example of the code if possible... lets use c: as example So i want to copy all .jpg files on c: that are bigger then 60Kb and im assuming if you give me that line i can just change the .jpg to .avi, .bmp, .mp3 whatever and actually even better if you could limit it between specific file sizes like 100kb-120mb so basically i backup restore alot of user computers i want to put in the thump drive it will backup the most common files they will need and i can restore without me wasting my time looking through files and seeing what i need to keep or not. also i am having an issue i have done everything exectly as described but my autorun.inf wont autostart and it wont do anything but open in notepad... im using windows 7
below is my script i have right now, i was using the other scripts but i really have no point i just double click on file.bat and everything works and i actually want to see whats going on so i turned echo on. I want to have on the bottom part where D:\ begins i want to copy that and have all of the letters scanned except the letter that the thumbdrive is on. I have this on my 16gb sdhc sdcard using a usb adapter. @echo on :: variables SET odrive=%odrive:~0,2% set backupcmd=xcopy /s /c /d /e /h /i /r /y echo on %backupcmd% &quot;%USERPROFILE%\Favorites&quot; &quot;%drive%\backup\favorites&quot; %backupcmd% &quot;%USERPROFILE%\Desktop\*.jpg&quot; &quot;%drive%\backup\img&quot; %backupcmd% &quot;%USERPROFILE%\Desktop\*.jpeg&quot; &quot;%drive%\backup\img&quot; %backupcmd% &quot;%USERPROFILE%\Desktop\*.bmp&quot; &quot;%drive%\backup\img&quot; %backupcmd% &quot;%USERPROFILE%\Desktop\*.3gp&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;%USERPROFILE%\Desktop\*.mp4&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;%USERPROFILE%\Desktop\*.avi&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;%USERPROFILE%\Desktop\*.wmv&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;%USERPROFILE%\Contacts&quot; &quot;%drive%\backup\contacts&quot; %backupcmd% &quot;%USERPROFILE%\Links&quot; &quot;%drive%\backup\links&quot; %backupcmd% &quot;%USERPROFILE%\My Documents\My Music&quot; &quot;%drive%\backup\mp3&quot; %backupcmd% &quot;%USERPROFILE%\My Documents\Downloads&quot; &quot;%drive%\backup\downloads&quot; %backupcmd% &quot;%USERPROFILE%\My Music&quot; &quot;%drive%\backup\mp3&quot; %backupcmd% &quot;%USERPROFILE%\My Documents\*.jpg&quot; &quot;%drive%\backup\img&quot; %backupcmd% &quot;%USERPROFILE%\My Documents\*.bmp&quot; &quot;%drive%\backup\img&quot; %backupcmd% &quot;%USERPROFILE%\My Documents\*.avi&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;%USERPROFILE%\My Documents\*.mpg&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;%USERPROFILE%\My Documents\*.3gp&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;%USERPROFILE%\My Documents\*.mp4&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;%USERPROFILE%\My Pictures&quot; &quot;%drive%\backup\img&quot; %backupcmd% &quot;%USERPROFILE%\Videos&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;%USERPROFILE%\Music&quot; &quot;%drive%\backup\mp3&quot; %backupcmd% &quot;%USERPROFILE%\Downloads&quot; &quot;%drive%\backup\downloads&quot; %backupcmd% &quot;D:\*.jpg&quot; &quot;%drive%\backup\img&quot; %backupcmd% &quot;D:\*.jpeg&quot; &quot;%drive%\backup\img&quot; %backupcmd% &quot;D:\*.bmp&quot; &quot;%drive%\backup\img&quot; %backupcmd% &quot;D:\*.3gp&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;D:\*.mp4&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;D:\*.avi&quot; &quot;%drive%\backup\vid&quot; %backupcmd% &quot;D:\*.wmv&quot; &quot;%drive%\backup\vid&quot; @echo on cls
<p>it only copy one file with same extention. but how we can copy many files with same extension</p>
hmm, is there a simple way i can exclude a specific folder? like say... &quot;AppData&quot;<br>it just keeps getting in the way.
just to update nevermind its working perfectly this computer is just highly customized and i have all of the autorun and everything off it works great on my other winxp computer.... but is there a way to not have the command box come up and say &quot; CreateObject(&quot;Wscript.Shell&quot;).Run &quot;&quot;&quot;&quot; &amp; WScript.Arguments(0) &amp; &quot;&quot;&quot;&quot;, 0, False &quot; also one more question, i still havent figured out how the do the above part with the sizes but i am having an issues with the pdf files i its taking everything from program files that is pdf and i really dont need those its taking like the pdf install and help files from installed programs is there a way to block specific locations from being copied from or for things like pdf and documents and i going to have to specify folders to look in?
You could get a batch to exe converter and most of them have options like run in background so it's an exe file but you can't see the command window when you run it.
There is in fact a way to not have a command box come up. The way I do it is:<br> +Write (and compile) a C file that runs your batch file's commands invisibly<br> <br> &nbsp;&nbsp;&nbsp;&nbsp; #include &lt;stdio.h&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp; #include &lt;windows.h&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp; int main()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; system(&quot;examplefile.bat&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (0);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> <br> <br> <br> +Write a VBS file that runs that compiled C program (now a shiny .EXE file)<br> <br> &nbsp;&nbsp;&nbsp; Set objSh = CreateObject(&quot;Shell.Application&quot;)<br> &nbsp;&nbsp;&nbsp; objSh.ShellExecute &quot;example-exe-file&quot;, &quot;&quot; , &quot;&quot;, &quot;&quot;, 0<br> <br> Now make sure they are all in the same directory, unless you want to get more complicated with your code. To start the invisible batch file, run the VBS file.<br> <br> This works because the VBS file can start a program invisibly, but it can only do this to executables (.EXEs). This doesn't include batch files (.BAT). However, the compiled C file is in fact executable. So the VBS runs the C, which runs the Batch as its own commands (that is to say, invisibly).<br> <br> For more help, just comment.<br> <br> By the way, I was about to write an instructable on that, but now I dont think it's necassary.<br> <br>
lol another question... so i want to add multiple drives to my script and i am having an issue where I put like the drive letters I want to scan and copy files from but when it tries to copy/scan on the drive litter that my thumbdrive is on it causes a problem and hangs. how do I get it to not scan the drive that its running on when its scanning for files? sorry so many questions but i have been playing with this thing all night and almost got it the way i want it other then these few things and I have been googleing all over to find out more info but not coming up with much.
hey please show me what to assign to folder for example if i want any bat file i say&quot; *.bat&quot; and for any file &quot;*.*&quot; what can i say for any folder any whare?? please ur blessed and show me
how would you coppy the documents folder please paste the code in the reponse.
<p>Yes, I will answer; Learn batch code. You really need that. It will make everything on your computer easier. For your needs:</p><p><em>@echo off</em></p><p><em>xcopy C:\Users\%USERNAME%\Documents E: /E /H</em></p><p>xcopy is a powerfool tool. Use it wisely! 'With great power, comes great responsibility.' ;P</p>
How can i root the files?And how did you do the icon?
No, you just copy all the files (.bat, .inf., .vbs etc) and copy them to the root of your stick, (example &quot;G://&quot;)
<p>but how</p><p>???</p>
<p>hey I want to copy only those files which are selected by user.........at some predefined location........to copy those files I will provide one option in right click context menu....</p>
<p>hey I want to copy only those files which are selected by user.......at some default location which is predefined.......</p><p>to copy the files I want to give one extra option when user right click on that file......</p>
<p>You can see this post:- http://goo.gl/dANahl</p>
<p>You can see this post: http://goo.gl/dANahl</p>
<p>Web Hosting in Rajahmundry&amp; Domain Name Registration Rajahmundry, Hosting Services Rajahmundry,Cheap Domain Registration Rajahmundry, Windows &amp; Linux Web Hosting Rajahmundry, Email Hosting Rajahmundry, RajahmundryWeb Hosting Company. For details contact http://onl9shoppy.com</p>
<p>Hey everyone I am having issues. I am trying to sync files from one folder to another when they plug in the USB drive. I have a .bat file that correctly syncs the folders. I have an autorun that changes the name of the drive and the icon. However, I can not get the autorun to run the .bat file. Any Ideas?</p>
<p>This is a problem that Windows Bill Gates himself discovered so he disabled autorun there fore stopping it froms starting pprograms other than from the computer and also this was only stoped from xp onwards and xp soo yeah...</p><p>Good luck</p><p>P.S for your trying to do this on an windows XP computer it will work unless they have trend micro office securiy it blocks all auto run features from outr side of the computer</p>
<p>I Like this page thanks</p>
<p>Thanks for the information made one, great for backups without having to click on a bunch of things. I did have to click on the autolaunch to execute but one button is a lot less thanks.</p>
could sombody modify this code so that it copys the entire hard drive.
<p>yes you could But You wold probs need a hars disk instead of a usb because It would be like 200G or more</p>
<p>Hi, I'd like to use this for backing up User profiles, and documents at my company and then later on restore that info onto their new computers. Is there anyway to make it so the backup folder automatically gets renamed to the User Profile's name?</p><p>So, I may backup multiple computers first and then later on know which documents belong to that particular user.</p>
<p>yes there is but You cant find it here go look on youtube.com </p>
If you have that much access to the pc, you could just make a batch script that copies all files and set it in the startup folder. It will run silently, and gets rid of the need for the obvious USB. Of course, you could keep the USB and have the batch file in the startup folder write to the USB.
Hello, love the product, but it does not auto run. Also for you venturous people out there, I made a simple manual kill command that will stop the process if you need to. <br> <br>~~~~taskkill /im cmd.exe~~~~ <br> <br>just put that in a .bat file and you are good to go.
One of the best ways to improve this would be to go through and correct the spelling and grammar errors. It REALLY makes it hard to follow your instructions when you don't use punctuation and run two sentences together. At one point, it took me several minutes to figure out what the hell you did to the sentence to finally understand what you were trying to say. <br> <br>Sorry if that sounds &quot;negative&quot; but a well-worded instruction would go very far in helping people to understand your process. <br> <br>Can't wait to give this a try!
I'm running windows 7 64bit pro. It does work. <br>CreateObject(&quot;Wscript.Shell&quot;).Run &quot;&quot;&quot;&quot; &amp; WScript.Arguments(0) &amp; &quot;&quot;&quot;&quot;, 0, False <br>make sure 1 one space between &amp; and WScript...
the .vbs didn't work for me so here's another I found on the Internet:<br> <br> Set WinScriptHost = CreateObject(&quot;WScript.Shell&quot;) WinScriptHost.Run Chr(34) &amp;&quot;*BatchPathHere*&quot; &amp; Chr(34), 0 Set WinScriptHost = Nothing<br> <br> - just because it may not work on other computers, - as well as mine
TO ALL WHO COULD USE AUTORUN ON WIN7 <br>well.. im srry 2 say but microsoft has disabled the autorun ability for usb in windows 7..as precaution since most malware come from usb. Soo if u wanna make it work its gotta be on windows 2000, xp, or vista(who uses 2000 anymore???)..and frankly there's nuthin u can do 2 change the autorun ability so you'll have to click on the launch.bat file if u wanna make this work..
hi,it works well,thank you.but there's a problem that it's not invisible when i click on the launch.bat a black window opens and begin to list all the files that i want to copy; <br> <br> HOW TO MAKE IT COPY THOSE FILES WITHOUT THAT BLACK WINDOW OPENS??? <br>can u plz help??
good tutorial, now i have 1 question... <br>how to stop/cancel copy ?
how about automatically copying all files from any USB plugged to the computer into the hard drive?
hi and thnx <br>i do as u told and it work properly except that i have to click on launch.bat file to start copy. what is the problem and what should i do? <br>Thanks again
This autorun will be captured and deleted by pretty much any AV that is installed. Also, autorun from USB does not work at all on Windows 7. <br> <br>This will still work by running the Launch.bat directly, but a silent autorunner is no longer possible on most PCs (for obvious reasons...like this one)
How ever late I may be. <br /> <br />It works....
does their computer need to be on/logged in?
hello <br>its really great subject but i just want to ask if want to copy the jpg files <br>but from the whole hard drive <br>not only form the C drive <br>i mean form the drive D,E,F..... etc <br>what should i write <br>and thanks alot
any way to make to see it when i press (for example) the &quot;c&quot; key?<br> thanks in advance
Doesn't work in windows 7, only Vista and XP, windows removed the autorun from flashdrives for security reasons.
i tryed your program but it wouldn't automatically come up

About This Instructable


529 favorites


More by bigdaddyclint: How to make flash drive that copy's users files silently and automatically
Add instructable to: