Solved

Error in creating bat file.

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now