Scheduled tasks won't start

R

Rafi Hecht

I currently operate a machine with Windows 2000 server on it, and am
trying to schedule a task that will execute a .cmd file every night at
a certain time. I tried to run it but it wouldn't go. I entered the
administrator password and the "task" ran. However, the process that
the file was supposed to do didn't. I was able to manually run the
script in the past simply by double-clicking it, but now I'm looking
for a shortcut. Any advice on this would be greatly appreciated.
 
P

Pegasus \(MVP\)

Rafi Hecht said:
I currently operate a machine with Windows 2000 server on it, and am
trying to schedule a task that will execute a .cmd file every night at
a certain time. I tried to run it but it wouldn't go. I entered the
administrator password and the "task" ran. However, the process that
the file was supposed to do didn't. I was able to manually run the
script in the past simply by double-clicking it, but now I'm looking
for a shortcut. Any advice on this would be greatly appreciated.

You need to give yourself some "eyes" so that you can see what's
going on. Use the Task Scheduler to run this batch file:

@echo off
echo %date% %time% Start of task > c:\test.log
echo User=%UserName%, Path=%path% >> c:\test.log
c:\Tools\YourTask.exe 1>>c:\test.log 2>c:\test.err
echo ErrorLevel of c:\Tools\YourTask.exe=%ErrorLevel% >> c:\test.log
echo %date% %time% End of task >> c:\test.log

Now have a look at the two log files and all will become clear.
 
D

Dave Patrick

Scheduled Tasks|Advanced|View Log may provide some details. If the job
connects to another machine you may need to add the user/ group 'logon as
batch job' rights (server side). Control Panel|Admin Tools|Local Security
Policy\Local Policies\User Rights Assignments
"Log on as a batch job"

Remember that if it involves network resources to make sure the user account
has permissions to the resources and also use UNC paths as mapped drives
won't exist when no one is logged on.

This article may help.

Result Codes in Scheduled Tasks Indicate an Error Occurred in the Task
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q267031


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
|I currently operate a machine with Windows 2000 server on it, and am
| trying to schedule a task that will execute a .cmd file every night at
| a certain time. I tried to run it but it wouldn't go. I entered the
| administrator password and the "task" ran. However, the process that
| the file was supposed to do didn't. I was able to manually run the
| script in the past simply by double-clicking it, but now I'm looking
| for a shortcut. Any advice on this would be greatly appreciated.
|
 
R

Rafi Hecht

Hi,

I've tried your method, and received the following code

from test.err:

The system cannot find the path specified.

from test.log:

Fri 12/02/2005 12:03:23.95 Start of task
User=Administrator, Path=
ErrorLevel of c:\Tools\YourTask.exe=3
Fri 12/02/2005 12:03:23.96 End of task

Do you know what any of this code means? What can I do to fix this
problem?
 
P

Pegasus \(MVP\)

You appear to have no default path defined, and I suspect
that you did not fully qualify the path to the task to be
executed. Instead of writing

"C:\Some folder\Some App.exe", you wrote
"Some App.exe"

Since the system is unable to locate "Some App.exe", the
task fails.

It would be helpful if you posted your whole batch file!
 
R

Rafi Hecht

Since I can't attach files, here's a copy/paste of what happened:

I created an eyes.bat file using your code (you told me to "create
eyes"):

@echo off
echo %date% %time% Start of task > c:\test.log
echo User=%UserName%, Path=%path% >> c:\test.log
c:\Tools\YourTask.exe 1>>c:\test.log 2>c:\test.err
echo ErrorLevel of c:\Tools\YourTask.exe=%ErrorLevel% >> c:\test.log
echo %date% %time% End of task >> c:\test.log

And I got this from "test.err":

The system cannot find the path specified.

And this from "test.log":

Sun 12/04/2005 12:03:00.06 Start of task
User=Administrator, Path=
ErrorLevel of c:\Tools\YourTask.exe=3
Sun 12/04/2005 12:03:00.10 End of task

That's it plain and simple. What could I possibly have done wrong, and
what can I do to correct it?
 
P

Pegasus

You're supposed to replace the line
c:\Tools\YourTask.exe 1>>c:\test.log 2>c:\test.err
with your own command that you're trying to run, e.g. like so:

"c:\program files\my application\run.exe" 1>>c:\test.log 2>>c:\test.err
 
R

Rafi Hecht

ok, this is what I just got when typing in the path name WITH
quotations:

in the test.log:

Mon 12/05/2005 17:05:41.06 Start of task
User=Administrator, Path=

ERROR: this script needs Windows 2000 or better. (we already have
windows 2000)

in the test.err:

Mon 12/05/2005 17:05:41.06 Start of task
User=Administrator, Path=

ERROR: this script needs Windows 2000 or better.

With the regular filepath, I get this:

from test.err:

'c:\Program' is not recognized as an internal or external command,
operable program or batch file.

from test.log:

'c:\Program' is not recognized as an internal or external command,
operable program or batch file.


At this point I'm baffled. Any additional help on this would be greatly
appreciated. Thank you.
 
R

Rafi Hecht

"Log on as a Batch Job" is already selected. That doesn't seem to do
the trick, unfortunately.
 
P

Pegasus

Unfortunately you did not show the latest version of
your batch file. Let's have a look at it! One thing,
however, is clear: You MUST surround your
executable file with double quotes if it contains embedded
space, as I showed in my most recent reply:

"c:\program files\my application\run.exe" 1>>c:\test.log 2>>c:\test.err
 
R

Rafi Hecht

I've tried that already, but I will try it again to show you what my
batch file now looks like and what I generate. By the way, your help so
far has been unbelievable. Thanks a million!
 
R

Rafi Hecht

Okay. This is the EXACT SYNTAX of the eyes.bat file that I have:

@echo off
echo %date% %time% Start of task > c:\test.log
echo User=%UserName%, Path=%path% >> c:\test.log
"c:\Program Files\xdbdown\xdbdown.cmd" 1>>c:\test.log 2>c:\test.err
echo ErrorLevel of "c:\Program Files\xdbdown\xdbdown.cmd"=%ErrorLevel%echo %date% %time% End of task >> c:\test.log

and here's what I have from test.err:

"The system cannot find the file specified."

and from test.log:

"Tue 12/06/2005 11:03:43.19 Start of task
User=Administrator, Path=

ERROR: this script needs Windows 2000 or better."

Now here's the thing. I am already running windows 2000 server, and the
filepath is correct! So right now I am at a loss at what to do here!
 
P

Pegasus

The file "c:\Program Files\xdbdown\xdbdown.cmd" is in
itself a batch file. This raises two questions:

a) Does it exist?
b) What does it contain?

Please cut & past its contents into your reply.
 
R

Rafi Hecht

a) Yes
b) Instructions to automatically download and install the latest virus
defs from the Symantec website.

Here's the whole code from the cmd file copied/pasted:

@set COPY_XDB_TO="c:\Program Files\Symantec AntiVirus\"
@set RAPIDRELEASE=1
@set XDBTEMP=%temp%

@rem
==============================================================================================
@rem Set RAPIDRELEASE=1 to download repidrelease definitions,
RAPIDRELEASE=0 for fully QA'd definitions (standard).
@rem Change COPY_XDB_TO= to point to the SAV CE server directory (or
where you want the XDB file copied)
@rem you can also run the script directly from the SAV folder and it
will copy the definitions there.
@rem XDBTEMP is the temp folder the script will use while downloading
definitions, set to %temp% to use system default
@rem
==============================================================================================
@rem Script for downloading virus definition updates for
@rem Symantec Antivirus Corporate Edition version 8.x and 9.x
@rem This unsupported utility is provided for your convenience only.
@rem Symantec Technical Support cannot provide support for the
creation,
@rem use, or troubleshooting of Windows scripts.

@rem
==============================================================================================
@echo off


rem ========= check that OS is win2k or better ============
if not "%OS%" == "Windows_NT" goto BADOS
if "%APPDATA%" == "" goto BADOS

rem ========= make sure to be in script directory ============
if exist rtvscan.exe set COPY_XDB_TO=%CD%
for %%i in (%0) do @%%~di
for %%i in (%0) do @cd %%~pi
if exist rtvscan.exe set COPY_XDB_TO=%CD%

rem =========== get name/size of last file from "xdbdown.lastfile"
============
if not exist xdbdown.lastfile goto NOLAST
for /f "tokens=1" %%f in (xdbdown.lastfile) do set lastfile=%%f
for /f "tokens=2" %%f in (xdbdown.lastfile) do set lastsize=%%f
:NOLAST

rem ========= jump to temp dir ============
if not exist "%XDBTEMP%\xdbtmp" md "%XDBTEMP%\xdbtmp"
if exist "%XDBTEMP%\xdbtmp\*.xdb" del "%XDBTEMP%\xdbtmp\*.xdb"
pushd "%XDBTEMP%\xdbtmp"

rem =========== make ftp script for checking xdb directory on ftp
===========
echo open ftp.symantec.com> check.txt
echo anonymous>> check.txt
echo (e-mail address removed)>> check.txt
set xdbfolder=xdb
if "%RAPIDRELEASE%" == "1" set xdbfolder=rapidrelease
echo cd AVDEFS/norton_antivirus/%xdbfolder%>> check.txt
echo dir *.xdb chk.lst>> check.txt
echo bye>> check.txt

rem =========== get filename and size from ftp ============
if exist chk.lst del chk.lst
ftp -s:check.txt
if not exist chk.lst goto ERROR
for /f "tokens=9" %%f in (chk.lst) do set xdbfile=%%f
for /f "tokens=5" %%f in (chk.lst) do set xdbsize=%%f
if "%xdbfile%" == "" goto ERROR
if "%xdbsize%" == "" goto ERROR

rem =========== compare ftp name/size to local ============
if not "%xdbfile%" == "%lastfile%" goto DOWNLOAD
if not "%xdbsize%" == "%lastsize%" goto DOWNLOAD
popd
echo.
echo Already downloaded latest %xdbfolder% file: %xdbfile% - size
%xdbsize%
echo %date% %time% Already downloaded latest %xdbfolder% file:
%xdbfile% - size %xdbsize% >> XDBdown.log
goto END

:DOWNLOAD
rem ========= make ftp script for downloading new xdb file =========
echo open ftp.symantec.com> down.txt
echo anonymous>> down.txt
echo (e-mail address removed)>> down.txt
echo cd AVDEFS/norton_antivirus/%xdbfolder%>> down.txt
echo bin>> down.txt
echo hash>> down.txt
echo get %xdbfile%>> down.txt
echo bye>> down.txt

rem ============= download new file =================
ftp -s:down.txt
for %%i in (%xdbfile%) do @set newsize=%%~zi
if not "%newsize%" == "%xdbsize%" goto ERROR
move %xdbfile% %COPY_XDB_TO%
if exist %xdbfile% goto ERRORMOVE
popd
echo.
echo %xdbfile% %xdbsize% > xdbdown.lastfile
echo Downloaded new %xdbfolder% file: %xdbfile% - size %xdbsize%
echo %date% %time% Downloaded new %xdbfolder% file: %xdbfile% - size
%xdbsize% >> XDBdown.log
goto END


:ERROR
popd
echo.
echo ERROR: problem downloading %xdbfolder% definition file.
xdbfile=%xdbfile% xdbsize=%xdbsize% newsize=%newsize%
(lastfile=%lastfile% lastsize=%lastsize%).
echo %date% %time% ERROR: problem downloading %xdbfolder% definition
file. xdbfile=%xdbfile% xdbsize=%xdbsize% newsize=%newsize%
(lastfile=%lastfile% lastsize=%lastsize%). >> XDBdown.log
type "%XDBTEMP%\xdbtmp\chk.lst" >> XDBdown.log
echo. >> XDBdown.log
goto END

:ERRORMOVE
popd
echo.
echo ERROR: problem moving definition file to SAV folder.
COPY_XDB_TO=%COPY_XDB_TO% newsize=%newsize% (lastfile=%lastfile%
lastsize=%lastsize%).
echo %date% %time% ERROR: problem moving definition file to SAV
folder. COPY_XDB_TO=%COPY_XDB_TO% newsize=%newsize%
(lastfile=%lastfile% lastsize=%lastsize%). >> XDBdown.log
goto END

:BADOS
echo.
echo ERROR: this script needs Windows 2000 or better.
echo %date% %time% ERROR: this script needs Windows 2000 or better. >>
XDBdown.log
goto END

:END
if exist "%XDBTEMP%\xdbtmp\check.txt" del "%XDBTEMP%\xdbtmp\check.txt"
if exist "%XDBTEMP%\xdbtmp\down.txt" del "%XDBTEMP%\xdbtmp\down.txt"
if exist "%XDBTEMP%\xdbtmp\chk.lst" del "%XDBTEMP%\xdbtmp\chk.lst"
rd "%XDBTEMP%\xdbtmp"
set COPY_XDB_TO=
set RAPIDRELEASE=
set lastsize=
set lastfile=
set newsize=
set xdbsize=
set xdbfile=
set xdbfolder=
set xdbtemp=
 
P

Pegasus

I suspect you're trying to run this product on a server
even though it may not be meant for a server.

The message
"ERROR: this script needs Windows 2000 or better."
is generated by this line in xdbdown.cmd:
if not "%OS%" == "Windows_NT" goto BADOS

You can prevent it from interfering by modifying the line like so:
rem if not "%OS%" == "Windows_NT" goto BADOS

To identify which line generates the error message
"The system cannot find the file specified.", you must do
a) and b) below:

a) Modify your own batch file like so:
L1 @echo off
L2 path %path%;%SystemRoot%;%SystemRoot%;system32
L3 echo %date% %time% Start of task > c:\test.log
L4 echo User=%UserName%, Path=%path% >> c:\test.log
L5 call "c:\Program Files\xdbdown\xdbdown.cmd" 2>&1 >c:\Symantec.txt
L6 echo ErrorLevel of "c:\Program Files\xdbdown\xdbdown.cmd"=%ErrorLevel% >>
c:\test.log
L7 echo %date% %time% End of task >> c:\test.log

I added L2 because you keep reporting that your path
is blank. This is inappropriate.

Remove the line numbers before running the batch file!

b) Remove the line "echo off" from xdbdown.cmd

You can now schedule the task and look in c:\Symantec.txt for
the string "The system cannot find the file specified".

By the way: The Subject line of this thread is obviously incorrect.
The scheduled task DOES start . . .
 
G

Gary Smith

I haven't seen anyone remark on the line
User=Administrator, Path=
in test.log. Is the path really empty when this batch file is executed?
If so, I'd expect to see "The system cannot find the file specified"
sooner or later.


Rafi Hecht said:
Okay. This is the EXACT SYNTAX of the eyes.bat file that I have:
@echo off
echo %date% %time% Start of task > c:\test.log
echo User=%UserName%, Path=%path% >> c:\test.log
"c:\Program Files\xdbdown\xdbdown.cmd" 1>>c:\test.log 2>c:\test.err
echo ErrorLevel of "c:\Program Files\xdbdown\xdbdown.cmd"=%ErrorLevel%
echo %date% %time% End of task >> c:\test.log
and here's what I have from test.err:
"The system cannot find the file specified."
and from test.log:
"Tue 12/06/2005 11:03:43.19 Start of task
User=Administrator, Path=
 
P

Pegasus

I commented on it in my most recent post, and I actually
set a default path in my proposed batch file.
 
R

Rafi Hecht

Interesting. Okay, I just applied the changes and now received the
following message from Symantec.txt:

ERROR: problem downloading rapidrelease definition file. xdbfile=
xdbsize= newsize= (lastfile=vd1f0e09.xdb lastsize=13608639).

Why would there be a problem? When I double-click the command file it
downloads nicely!
 
P

Pegasus

This sounds like a question for the Symantec FAQ pages.
Remember my suspicion that you're trying to run the product
on a platform for which it may not be designed.
 

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