Batch file to backup directory


this is a rather simple task, but I've forgotten the exact commands. I want the batch file to run under scheduler in this way:

1 - at 6pm, scheduler runs the backup.bat file, NO command prompt windows should pop up. (Win95/98).

2 - batch files does an XCOPY [dir1] [dir2]. with /S /E /C /H /Y . did I miss out anything? I want it to copy over updated and new files only. not the entire directory.

3 - manual clicking the batch file should run the XCOPY too. how do I do it without popping up the command window?



Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

rin1010Connect With a Mentor Commented:


Along with the parameters you're using, add the /i and /k switches...
The /i switch eliminates prompting about a directory if your copying multiple files.
The /k switch will copy the file's attributes and not reset any read-only attributes.
This may not apply to what you're currently copying but may be needed at some future time.
Also note that some of these switches apply only when running XCOPY under Windows
as you specify, but are the ones to get everything.

To copy "updated and new files only" append the /d switch, which copies only newer files
if a date isn't given. Alternatively, the /m switch will copy only changed files
but will alter the archive attribute to manipulate the files.

Using your examples, the batch file would be something like this:

@echo off
xcopy /h /i /c /k /e /r /y /d dir1 dir2

To get the batch file to run minimized, create a PIF to control it.
In Explorer, right-click your batch file and choose "Properties" from the ensuing menu.
In the "Run" field on the "Program" tab select "Minimized."
Adding CLS as the last line of your batch file will make it close under Windows,
but you can also choose the option to "Close on Exit" in the PIF properties.
You may find other useful PIF properties under some of the tabs
that will apply to your batch file.

Please post back if you want more about it or if these methods don't do it like you want.
1) Since you are running on 95/98 I would suggest to use a tool like WinCron (works lke a crontab under UNIX). To my knowledge the AT command is not implemented in 95/98.
2) I would add the /M option. This will allow to only copy files with the archive bit set and it will reset the archive bit on these files.


CLS clears the screen in a batch file. I take it you meat to use EXIT

Thanks, Lambert, but no, I meant that the CLS (clear screen) command
will close a dos box (window) when affixed as the last line of a batch file
running under the Windows versions doebuck mentions.
The EXIT command would terminate and remove from memory
the current copy of the COMMAND.COM command interpreter
and would close it if you shelled a dos session and ran it manually.

But in the context of "clicking the batch file" as doebuck indicates,
as opposed to typing the batch file's name in a Windows dos box,
you can test it yourself with a couple of simple batch files...



If the batch file is run from a shortcut or winfile or explorer or in a similar manner,
when the screen is cleared the window will close. Other results will occur
depending on previous commands in the script and whether it's run in dos mode, etc.,
where you probably wouldn't want to use the exit command. To see what I mean,
launch these examples from explorer and then manually from a command prompt:

@echo off

@echo off

@echo off

@echo off

doebuckAuthor Commented:
hey thanks guys!
I thought nobody bothered answering my question, as my email did not notify me for quite sometime.

rin1010, thanks. that's really what I need. BTW, do you know if it's possible still, to make a 'synchronization' instead of a backup, from a batch file?

say if dir1\file1 and dir2\file1 is compared and if the latter is newer than the former, it'll overwrite the other way round?
All Courses

From novice to tech pro — start learning today.