Question

  • Creator
    Topic
  • #4049156

    Xcopy in a bat file not copying any files – Win 11

    by rjmaccts ·

    Tags: 

    https://tek.io/3mSttAb

    Hi Mark, all:

    I’ve created a bat file to run basic xcopy to move Documents, Pictures, Desktop content to external drives. On a friend’s brand new Dell laptop running Windows 11, the batch file runs but 0 files copied.

    Here’s a sample line:
    xCopy “C:\Users\Robert\Desktop\*.*” d:\Robert\Desk /s /y /v /i /q /h /r /m

    Strangely, when I open a CMD window and paste such a command in it, it WORKS! So, why not in the bat file?

    Perplexed,
    Robert

You are posting a reply to: Xcopy in a bat file not copying any files – Win 11

The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our Community FAQs for details. All submitted content is subject to our Terms of Use.

All Answers

  • Author
    Replies
    • #4049547

      Reply To: Xcopy in a bat file not copying any files – Win 11

      by seatyboie ·

      In reply to Xcopy in a bat file not copying any files – Win 11

      There might be several reasons why your xcopy command isn’t operating properly when executed from a batch file. Check that the file paths in your xcopy command are valid and that the files you’re attempting to copy exist in the given folders. It’s conceivable that your routes aren’t what you believe they are, especially if you’re utilising relative paths.
      Also, ensure that the user account that is running the batch file has access to read the files in the source directories and write to the destination folders. This might be the cause of the problem if the batch file is executing with different permissions than when you run the command from the command line.

    • #4051749

      DUH!

      by rjmaccts ·

      In reply to Xcopy in a bat file not copying any files – Win 11

      I was using the /m qualifier and, since all the files had been backed up, “0 files found.” Once I removed it and didn’t have it ignore files that had been backed up, it backed up all of them – which I wanted anyway, since I used a new external backup drive with no files on it.

      After running the initial backup, I put the /m back in.

      Thanks for your response and sorry for the trouble!

      Robert

    • #4051812
      Avatar photo

      Reply To: Xcopy in a bat file not copying any files – Win 11

      by Mar Gia ·

      In reply to Xcopy in a bat file not copying any files – Win 11

      It’s possible that the issue is related to the way the batch file is being run. When you run the command manually in a CMD window, it may be running with different permissions or settings than when it’s run from the batch file.

      You can try adding the command “pause” at the end of your batch file, which will allow you to see any error messages that may be generated during the xCopy process. Additionally, you can try running the batch file as an administrator to see if that resolves the issue.

      Another potential issue is that the paths in your xCopy command may not be correct. Make sure that the source and destination paths are valid and that there are no typos or other errors in the command. You can also try using the full paths for both the source and destination, rather than using variables like %USERPROFILE%.

      Finally, it’s worth checking if there are any antivirus or security software running on the computer that may be interfering with the xCopy process. These programs may be blocking the batch file from accessing certain files or folders. If you suspect this is the case, try disabling the antivirus software temporarily and see if that resolves the issue.

      Majan Wala

      • This reply was modified 6 months, 2 weeks ago by Avatar photoMar Gia.
      • This reply was modified 6 months, 2 weeks ago by Avatar photoWizard57M-TR. Reason: removed link
Viewing 2 reply threads