Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9152737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:07:42+00:00 2026-06-17T12:07:42+00:00

For example, in a batch file, I typed the command below: xcopy C:\fileA.txt D:\Dir\

  • 0

For example, in a batch file, I typed the command below:

xcopy C:\fileA.txt D:\Dir\ /y /d

It will fail absolutely if there was not a file called fileA.txt. But I want to know if it fails, then output some messages to user. How can I do this?

Any help will be grateful, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:07:43+00:00Added an answer on June 17, 2026 at 12:07 pm

    Most commands/programs return a 0 on success and some other value, called errorlevel, to signal an error.

    You can check for this in you batch for example by

    if not errorlevel 0 goto ERR
    

    xcopy errorlevels:

    0 – All files were copied without errors

    1 – No files were found to copy (invalid source)

    2 – XCOPY was terminated by Ctrl-C before copying was complete

    4 – An initialization error occurred.

    5 – A disk-write error occurred.

    [1] http://m.computing.net/answers/dos/xcopy-errorlevels/7510.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any example on DOS Batch - Find and Replace command for files?
I have a batch file with for example cd c:\test But there is more
I'm trying to schedule run multiple pythons using batch file. For example there are
I am using the batch file example below that I got from batch file
This is my requirement in windows batch file I tried the following Example: f1.txt
The following command in a batch file does not work as expected/hoped: echo %~nxs1
I need a batch file command which will select user's directory path (user input)
Can a Windows batch file determine its own file name? For example, if I
I try to run a batch file with the following code: wget.exe http://example.com/file0%24.html The
I need to write a batch file that will search a folder for all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.