Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Help with a batch file

18 Nov 2014   #1

Windows 8.1 Pro
Help with a batch file

I created a simple batch file to run XCOPY and copy all files and folders from a users directory to an external hard drive. The batch file works, but sometimes it will ask to copy all files Yes/No/All. The user has to select "a" in order for the batch file to continue.

I want to set a task scheduler to execute the batch file, but if this prompt comes up and the user isn't in front of the computer when it executes, the batch file closes out after a certain amount of time and never copies the files and folders.

My question, is there a switch to add to the batch file to choose All if asked? If so, what do i need to add to the batch file?

This is the line i have in the batch file, XCOPY C:\Users\Username\* F:\backup /s /i

My System SpecsSystem Spec
19 Nov 2014   #2

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan

Hi Natssdad,

Quote   Quote: Originally Posted by natssdad View Post
... but sometimes it will ask to copy all files Yes/No/All.
XCopy is asking you whether or not it should overwrite destination files.

Quote   Quote: Originally Posted by natssdad View Post
Is there a switch to add to the batch file to choose All if asked?
Yes, sort of. The /Y switch will tell XCopy to overwrite files in the destination; effectively supressing the 'Yes/No/All' prompt.

Alternately, you could just stimulate an 'a' key to the command by piping the output from echo.
echo a | XCOPY C:\Users\Username\* F:\backup /s /I

Nevertheless, you should be using ROBOCOPY for backup routines.

Robocopy is far more flexible switch wise (over 80 unique switch options) and provides detailed information and statistics of its actions. Also, it is comparably faster than other methods of copying. Part of the secret in its speed lies in the fact that it ignores files for copying if it has not be modified (in the source location) since the last backup routine (also a switch is available to help further speed up the copying process by multithreading). This makes Robocopy a much more quicker choice over XCopy, especially for backing up large amounts of data.

ROBOCOPY "C:\Users\Username" "F:\backup" /s
(Append the /MIR switch if you want Robocopy to instead mirror the complete directory tree of the source location)
My System SpecsSystem Spec
19 Nov 2014   #3

Windows 7 Pro 32

Tutorial for ROBOCOPY here: ROBOCOPY - Create Backup Script
My System SpecsSystem Spec

19 Nov 2014   #4

Windows 8.1 Pro

Thank you very much! That worked. I'll definitely check out ROBOCOPY

Thanks again.
My System SpecsSystem Spec

 Help with a batch file

Thread Tools

Similar help and support threads
Thread Forum
How can I write a batch file that opens a file in a program?
I wrote this batch file which does what I want it to do so far. @echo off "C:\Users\xxxxxx\Documents\HideTaskbar\HideTaskbar.exe" "C:\Program Files (x86)\VideoLANold\VLC\vlc.exe" "C:\Users\xxxxxx\Documents\HideTaskbar\ShowTaskbar.exe" exit
General Discussion
I need a batch file to open a random file within a certain folder/path
I want a batch to select and open a random link file in a folder i have. All the links are music videos I like to listen to, and I kind of want to just have an option for 'surprise me!'. I can change the file names if I have to, and I have a basic batch file ability. I know the simple commands,...
General Discussion
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
batch file open file for program in the startup folder
I have a computer that is a drone specifically for an outside LED sign. This computer is designed to never shut off and doesn't have any other program on it besides Operating System and the sign software. I need to create a batch file that I can place in the "start-up" folder that will open the...
General Discussion
How to create a batch file that will move files based on the file type
How to create a batch file that will move files based on the file type? My Requirement : I need a batch file to copy all .doc files in all my HardDisk to a removable disk say (Z: drive) . Can anyone make it possible using a batch file?Please...Its urgent...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:21.

Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App