Solved Help with a batch file

natssdad

New member
Local time
4:29 PM
Messages
2
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 Computer

Computer type
Laptop
Computer Manufacturer/Model Number
IBM Lenovo
OS
Windows 8.1 Pro
CPU
Intel Core 2 Duo 2.5Ghz
Memory
4GB
Hard Drives
160GB
Antivirus
AVG
Browser
Google Chrome
Hi Natssdad,

... but sometimes it will ask to copy all files Yes/No/All.
XCopy is asking you whether or not it should overwrite destination files.

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.
Code:
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.

Code:
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 Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
HP Elitebook 8540p
OS
Windows 7 Pro 32
CPU
Intel(R) Core(TM) i5 CPU M 540 @ 2.53GHz
Motherboard
Hewlett-Packard 1521
Memory
4,00 GB (Usable 2,98)
Graphics Card(s)
NVIDIA NVS 5100M
Sound Card
NVIDIA High Definition Audio
Screen Resolution
1600x900
Hard Drives
INTEL SSDSA2CW120G3
Antivirus
F-Secure Internet Security
Browser
IE, Firefox, Opera
Other Info
Sandboxie,
SRP (Software Restriction Policy),
EMET (Enhanced Mitigation Experience Toolkit),
WFC (Windows Firewall Control by BiniSoft),
Malwarebytes Premium
Thank you very much! That worked. I'll definitely check out ROBOCOPY

Thanks again.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
IBM Lenovo
OS
Windows 8.1 Pro
CPU
Intel Core 2 Duo 2.5Ghz
Memory
4GB
Hard Drives
160GB
Antivirus
AVG
Browser
Google Chrome
Back
Top