Solved

Error in creating bat file.

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

785 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