Windows XP scheduled task runs intermittently

On a client's computer running Windows XP
I have a task scheduled to run at 2:00 AM on Tuesday through Saturday.
The task is a batch script (.bat file).
It has been running fine for years.

After a scanner was installed on the system (by someone else) about a month ago, it stopped working.  (I'm not sure if the failure started IMMEDIATELY after the scanner was installed, but it is the only thing my client could think of that happened at about the same time.)

But it still works occasionally, e.g. for the first few days of October it ran.
On the scheduled tasks window (on a day when it did NOT work):
   the Last Run Time is shown as 2:00 AM
   the Last Result is 0xff

If when at the computer during the day I change the scheduled time to be in a two minutes, then wait two  minutes, it runs fine.

In the scheduler log file c:\windows\SchedLgU.txt
  - the task is logged as starting AND finishing at 2:00 AM
  - the completion code of 0xff is logged.

In the task scheduler Task / Run field, I specify just the full name of the batch file.
The batch file:
  - begins with multiple comment lines starting with "::" on each line
  - the first executable statement is "call setymd.bat"
  - setymd.bat is located in the same folder
  - the first thing setymd.bat does is create a small text file
  - that text file does NOT get created when the task does not run

Hence I conclude that the failure occurs before the batch file even starts, e.g. perhaps during cmd.exe startup.
The computer is left on all night, and I believe it does not go into a
sleep mode.  (I have checked the "wake the computer.." option, just in case.)

Does anyone have any ideas of what might be causing this failure?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Since the return value (errorlevel) is not 0x0 but sometimes 0xff I would first suggest to have a look into the scriptcode itself. An errorlevel of 0xff can have several causes but one is a syntax error within the scriptcode. Since the script sometimes will run it can also be a sort of dependency.
You probably already did check if the script and all sub-scripts were changed recently by checking the modified date of these files.
Might it be possible to let us know the or some code of the scripts ?
MatthewNicollAuthor Commented:
The first executable statement is  "call setymd.bat".

The first executable in setymd.bat is:
  echo dummy | makeset ymd -d:YYYY-MM-DD > tsetymd.bat

makeset.exe is a utility of my own creation (which I have been using for years).

When the job fails to run, the file tsetymd.bat is not created.
Hence I had assumed that the batch job never even starts.

I guess I should insert debug statements (e.g. echo stmt 1 >> logfile.txt)
into the primary batch file to see how far it gets.

I thought I'd ask here first to see if there is some weirdness with the XP scheduler I wasn't aware of.

Don ThomsonCommented:
You said that the PC stays on all night but does it stay logged on.  With Scheduled events, they will only run when the user is logged on unless you tell it to run using the usercode/pwd cobo that has the rights to run the batch file. If the user changes their password then they need to go in and modify the credentials in the scheduler. It will alway run when you set the scheduler to run in a couple of minutes as you are logged in. The scheduler will always run if you are logged in and only looks at the credentials if the user is logged out.  It then logs in - runs the program then logs out again.
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Thanks for the feedback. You can indeed try to insert some debug statements into the primary batch file. But please keep in mind that if there is a syntax fault in the rest of this script you still would get a 0xff. So you might want to try to temporary have a smaller version of the primary script with only the debug statements and call to the other script.

Furthermore, is this task running with a separate user or with the user which you also use to logon.
I assume the password is correct otherwise the error (0xff) would be differently.
I also assume the Power Options are set correctly so the computer won't go to standby mode as the scheduler logfile contains an entry that it did try to run.
MatthewNicollAuthor Commented:
... bit of a delay, I was sick, the client has gone on holiday, and it hasn't failed since I inserted the debug statements.  Should get results next week.
MatthewNicollAuthor Commented:
The main batch file starts with the following statement:

    Call setymd.bat

setymd.bat starts with the following statement:

    echo dummy | makeset.exe ymd -d:YYYY-MM-DD > tsetymd.bat
and this is where it crashes - only when run as a scheduled job,
and then not always!

makeset.exe is a program of my own creation which has been running
successfully for years on the client's computer.

Since the crash is happening in my own exe, I will close this issue.

I will try replacing makeset.exe and if that doesn't work, I'll
find some other way of putting the date in yyyy-mm-dd format into
an environment variable.
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
MatthewNicollAuthor Commented:
Below is the solution I found to the problem.  If you think it might be useful as a reference, keep his thread.  If not, I will not object if you delete it.

The job involved several batch files and a custom exe.  I  narrowed the intermittent failure down to where the exe file was being invoked.  I re-wrote the whole thing in VB Script, and it has been running successfully now for over a week.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Very good you could narrow it down and found a solution for the problem.

@LeeTutor, in this kind of situations it's difficult to give a full answer immediately. We tried to help here by sorting out when you get such an error and what you can do to troubleshoot.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.