?
Solved

Error in creating bat file.

Posted on 2008-10-03
5
Medium Priority
?
788 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 800 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 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