Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Hey folks, I'm attempting to use xcopy to copy over a file from one machine to another on our network as part of a Java program. I'm calling xcopy like this:

xcopy "C:\Program Files\path\to\my\file" "\\othermachine\c$\Documents and Settings\<myUserName>\Desktop\Test\path\in\directory\structure\to\file" /e /y /i

Because I'm calling it from with in Java, I need all the prompts to be suppressed. For the most part, \i and \y have done exactly that. However, for this one file /i fails and I get the file or directory prompt. The result is that it hangs the entire program.

I've also tried calling it with /s /t /q appended on to the existing options, to no avail. Why isn't /i working to suppress the File or Directory prompt? Is there an order I need to call the options in? Is there something else I need to do?

EDIT: I should mention, the file is a text file - single line of text. It does not have an extension. It looks like this: FILE-NAME

share|improve this question
add comment

4 Answers 4

up vote 8 down vote accepted

echo F does the trick:

echo F | xcopy "C:\Program Files\path\to\my\file" "\\othermachine\c$\Documents and Settings\<myUserName>\Desktop\Test\path\in\directory\structure\to\file" /e /y /i

Note that the character may differ in localized versions (my german one expects D for file (Datei) or V for directory (Verzeichnis))

share|improve this answer
add comment

A seemingly undocumented trick is to put a * at the end of the destination - then xcopy will copy as a file, so

xcopy c:\source\file.txt c:\destination\newfile.txt*

The echo f | xcopy ... trick does not work on localized versions of Windows, where the prompt is different.

share|improve this answer
    
thanks for this hint, didn't knew that :-) –  Beachwalker Jul 7 '13 at 12:43
add comment

This thread on Stackoverflow has no marked answer, but it may help you (seems to be the same question).

share|improve this answer
    
Thanks for the suggestion, but that's a rather different scenario. That's suppressing the terminal itself when calling a batch file. I'm trying to suppress a prompt that xcopy gives. –  Daniel Bingham Sep 2 '09 at 14:30
add comment

I've always found a useful cheat for these situations to have a text file with a Y in it and tag < y.txt on the end of the xcopy

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.