Solved

Error in creating bat file.

Posted on 2008-10-03
5
777 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
  • 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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 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