Batch file not working as a scheduled task

D

David

Running Windows 2000 SP2

The batch file works just fine when started outside of the scheduled
tasks, but when run as a scheduled task it fails.
I believe it is a problem with the Command Extensions - ie. my batch
file is using them, and they are not enabled. I get the following
errors :

'date /t' is not recognized as an internal or external command,
operable program or batch file.
'time /t' is not recognized as an internal or external command,
operable program or batch file.

The lines are :

for /f "tokens=1,2,3,4* delims=/ " %%K in ('date /t') do set day=%%L &
set month=%%M & set year=%%N
for /f "tokens=1,2 delims=: " %%T in ('time /t') do set hour=%%T & set
minute=%%U

It's an inherited script, and I have evidence of it working in the
past. I have a suspicion that SP2 has been applied since that time.

The ultimate goal is to rename a file with a time and date included
before archiving it. If there is an alternative way then I'm more
than happy to ditch what I've got now!!

TIA
David.
 
P

Pegasus \(MVP\)

David said:
Running Windows 2000 SP2

The batch file works just fine when started outside of the scheduled
tasks, but when run as a scheduled task it fails.
I believe it is a problem with the Command Extensions - ie. my batch
file is using them, and they are not enabled. I get the following
errors :

'date /t' is not recognized as an internal or external command,
operable program or batch file.
'time /t' is not recognized as an internal or external command,
operable program or batch file.

The lines are :

for /f "tokens=1,2,3,4* delims=/ " %%K in ('date /t') do set day=%%L &
set month=%%M & set year=%%N
for /f "tokens=1,2 delims=: " %%T in ('time /t') do set hour=%%T & set
minute=%%U

It's an inherited script, and I have evidence of it working in the
past. I have a suspicion that SP2 has been applied since that time.

The ultimate goal is to rename a file with a time and date included
before archiving it. If there is an alternative way then I'm more
than happy to ditch what I've got now!!

TIA
David.

Strange - it works OK for me.

A simpler way of getting the day and the hour would be to extract
them from %date% and %time%. These env. variables are defined
under Win2000/XP.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top