S
S
sflyer2016-12-19 06:09:35
cmd/bat
sflyer, 2016-12-19 06:09:35

Why doesn't the bat script delete files (running from the scheduler)?

There is a bat script for copying and deleting files. If you run it manually, then the script works. However, if you run the script from Task Scheduler, the files are copied but not deleted. What am I doing wrong? Code below. OS Windows Server 2008r2.

net use T: \\server\share  /USER:server\user password
IF EXIST I:\SQL\base\base_backup*.bak (
    copy NUL I:\SQL\base\base.chk
    copy I:\SQL\base\base_backup*.bak T:\share
    copy I:\SQL\base\base.chk T:\share
    DEL I:\SQL\base\base*
    ) 
  ELSE (
        echo error 
    )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2016-12-19
@sflyer

Check the access permissions on i:\sql\base, for the user under which the batch file from the scheduler works.
It is useful for the batch file to write a log, redirect the errors of each command to the log, for example like this:

sel "LOG=%~dpn0.log"
1>nul 2>>"%LOG%" del /f /q I:\SQL\base\base*

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question