Scheduling a Batch File as an Event

  • Thread starter Thread starter Jenny
  • Start date Start date
J

Jenny

I'm attempting to get a batch file I have created (that
copies files from 1 directory to another directory by
stopping/restarting services that lock those files) to run
as a scheduled task. The batch file runs perfectly when I
attempt to run it manually, but when I try to run it as a
scheduled event, it stops after executing the "remove
directory" command. The commands I'm using are pretty
simple:

@Echo Off

Net Stop "Service Name1"

Net Stop "Service Name2"

Net Stop "Service Name3"

rd "D:\Main Directory\file folder\files\" /q/s
xcopy "M:" "D:\Main Directory\file
folder\files\" /e/q/h/y/r/i


Net Start "Service Name3"

Net Start "Service Name2"

Net Start "Service Name1"


I've checked and rechecked to ensure I'm using the
administrative user/password when scheduling the event,
but am still not having any luck. The directory gets
removed just fine, but the file copying doesn't happen at
all. Any ideas why this may be happening and/or possible
solutions would be greatly appreciated! :)
..
 
Jenny said:
as a scheduled task. The batch file runs perfectly when I
attempt to run it manually, but when I try to run it as a
scheduled event, it stops after executing the "remove
directory" command. The commands I'm using are pretty
simple:

Here's someplace to start. Redirect the stdout and the stderr for each
command to a file and after running it from the task scheduler check the
file to see if it shows an error or gives some other clue.

Net Stop "Service Name2" >> c:\testlog.txt 2>&1
Net Stop "Service Name3" >> c:\testlog.txt 2>&1
rd "D:\Main Directory\file folder\files\" /q/s >> c:\testlog.txt 2>&1
xcopy "M:" "D:\Main Directory\file folder\files\" /e/q/h/y/r/i >>
c:\testlog.txt 2>&1

etc etc...
 
thanks for the reply. it actually turned out to be an
issue with the mapped drive. Once I switched to using the
UNC path instead, the problem was solved. Thanks again
for all the pointers!
 
Back
Top