We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Batch file prematurely terminates

Medium Priority
651 Views
Last Modified: 2013-11-10
I have a batch file that runs an xcopy over the network to copy the contents of a harddrive from an older computer to a special folder on the new computer.  It's worked fine until recently it was modified to copy a few other folders over in separate xcopy commands.  Now it does the main xcopy (the first of the three at the bottom), then it stops and doesn't finish after that.

If after it fails to finish everything I need it to, I modify the file to remove everything between the set command and the last two xcopy commands, it will go through fine, so it's not that somethings typed wrong down there.

Does anyone know why it may prematurely terminate the file before finishing all of the xcopy commands?

This is being used with Windows XP.  If you need any more info, just ask :)
Echo off
 
set /p source="Enter Source Computer Service Tag: "
 
xcopy "\software\xcopy\exclude.txt" "C:\" /y /e /c /h /i
xcopy "\software\xcopy\xcopy.bat" "C:\Install" /y /e /c /h /i
 
 
mkdir "C:\old harddrive"
mkdir "C:\old harddrive\Notesbackup"
C:
cd \old harddrive
 
 
xcopy "\\%source%-company\C$\*.*" /y /e /c /h /i /exclude:C:\exclude.txt
xcopy "\\%source%-company\C$\program files\lotus\notes\*.*" "C:\old harddrive\notesbackup\program files\lotus\notes" /y /e /c /h /i
xcopy "\\%source%-company\C$\program files\wherenet\*.*" "C:\program files\wherenet" /y /e /c /h /i
 
pause

Open in new window

Comment
Watch Question

IT Consultancy
CERTIFIED EXPERT
Commented:
The bit mentioning xcopy.bat worries me.... if you call it that then it likely to get called instead of xcopy ... can I suggest this is called something else?

If you remove the echo off from the bbatch file can you post the output it produces please if that isn't it.

regards

Steve

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Steve KnightIT Consultancy
CERTIFIED EXPERT

Commented:
You haven't got an mkdir.bat or mkdir.cmd too have you?

Author

Commented:
Alright, I'll try removing the xcopy.bat part, it's not really needed anymore anyways.  If that doesn't work I'll come back with the echo off results.

Nope, no mkdir.bat or mkdir.cmd files.
Steve KnightIT Consultancy
CERTIFIED EXPERT

Commented:
Fair enough.... sorry for asking the seemingly obvious!

It depends where you run this from but if it is from c:\install or if c:\install is on your path then the second xcopy is copying that batch file into c:\install and then the next xcopy command further down would run xcopy.bat rather than xcopy.exe.

Anyway as you say give it a try and remove any xcopy.* that are lying around for starters and come back if needed.

Steve

Author

Commented:
Alright, I've just started a data transfer today.  It's a long distance transfer though, so it probably won't get done until tomorrow.  Since I don't work on Fridays, it will be Monday before I can get back to you, but I will let you know what happens one way or another.  I do think you're right about the xcopy.bat thing though.  It makes sense and is kind of obvious now that you pointed it out.

Author

Commented:
Thanks, looks like you were right.  After I removed the xcopy.bat file, it worked fine.

Thanks for your help Dragon
Steve KnightIT Consultancy
CERTIFIED EXPERT

Commented:
No problem, glad it helped.... we've all done it and scratched heads wondering why something doesn't do what you expect...... bat and cmd always run before an exe of the same name...

Steve
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.