Solved

Error in creating bat file.

Posted on 2008-10-03
5
778 Views
Last Modified: 2012-05-05
Hi,
I have created a bat file as in the snippet below, and saved it as c:\xcopy.bat.

I want the file to copy updated PDFs from a network drive to the PC and log which files have been transferred.  When I copy and paste the code into a command window, it runs fine, and I get the log file I want.  However when I save the .bat file and try to run it, she screen fills up with the message "The Process cannot access the file because it is being used by another process" and the log file comes out as attached.

Any help as to why the bat file is not working properly would be appreciated.
echo ******************** >> copylog.txt
echo Copy Started on %DATE% %TIME% >> copylog.txt
echo ******************** >> copylog.txt
XCOPY "X:\SHOPS POS\PDF" "C:\Documents and Settings\Administrator\Desktop\PDF" /D /Y /Z >> copylog.txt
echo ******************** >> copylog.txt
echo Copy Finished on %DATE% %TIME% >> copylog.txt
echo ******************** >> copylog.txt

Open in new window

copylog.txt
0
Comment
Question by:nauthencharge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 200 total points
ID: 22633779
Do not save it as xcopy.bat
xcopy is already a valid command in your path...rename it and retry (call it myxcopy.bat if you'd like)
0
 

Author Closing Comment

by:nauthencharge
ID: 31502744
Brilliant, Thanks!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22633815
Happy to help - thanx for the grade! :^)
0
 
LVL 7

Expert Comment

by:Hubasan
ID: 22633824
Hi nauthencharge,

Two things here:
1) Rename your BAT file to something other than "xcopy" since that is reserved for XCopy utility used by windows.
2) place backslash at the end of the copy destination path. Below is your corrected code you can use:

echo ******************** >> copylog.txt
echo Copy Started on %DATE% %TIME% >> copylog.txt
echo ******************** >> copylog.txt
XCOPY "X:\SHOPS POS\PDF" "C:\Documents and Settings\Administrator\Desktop\Config\" /D /Y /Z >> copylog.txt
echo ******************** >> copylog.txt
echo Copy Finished on %DATE% %TIME% >> copylog.txt
echo ******************** >> copylog.txt

Open in new window

0
 
LVL 7

Expert Comment

by:Hubasan
ID: 22633831
ooops, to late...hehehe...sirbounty is fast man!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question