# Backup batch program



## brooke (Feb 2, 2000)

I am trying to write a simple DOS batch program that will backup everything in my users' MY DOCUMENTS. The problem is if I just do a COPY C:\MY DOCUMENTS\*.*, it only backs up the single files under the directoy, but none of the folders the user has created in their MY DOCUMENTS directory. I don't have to write a separate copy statement for every folder, do I? Isn't there a "shortcut" statement that will copy all the folders and files underneath them?


----------



## Rockn (Jul 29, 2001)

Depending on the OS you could use the XCOPY command with the appropriate switches. To find out what switches are available type XCOPY /?


----------



## brooke (Feb 2, 2000)

Thanks bunches! The /E switch copies all directories and subdirectories, even empty ones...
It worked like a charm!


----------



## brooke (Feb 2, 2000)

One more thing...how do I get the batch program to automatically exit at the end and return to the desktop? Right now I have to close the little black box after it gets done running. I put an EXIT command at the end, but it's not exiting.


----------



## IMM (Feb 1, 2002)

Try it this way.
I'll assume the batch file looks like:

```
c:\windows\command\xcopy c:\mydocu~1\*.* c:\myback /e /y /i
```
Change it to read:

```
@echo off
c:\windows\command\xcopy c:\mydocu~1\*.* c:\myback /e /y /i > NUL
```
The "> NUL" bit sends the normal screen output to a bitbucket.
Now make a shortcut to the batch file and edit the shortcut so that it's set to run minimized and the 'close on exit' box is checked.
Move the shortcut to your desktop (or whatever is convenient) and call the shortcut rather than the batch file.
You should get a box on the task bar briefly - but that's all.

As an aside the "> NUL" portion could be something like ">> c:\somepath\myback.log" instead to append to an existing log file.


----------

