This can happen for a number of reasons:
- The folder c:\it\pcinfo does not exist
- c:\it\pcinfo\batch.log is a folder
- The task does not have sufficient access rights to the log file
Run the job under the ***command prompt*** and under
the ***same account*** as you scheduled it. This will
immediately show you the cause of the problem!
"mattr2110" <(E-Mail Removed)> wrote in message
news:87687F0E-0760-4799-8FB5-(E-Mail Removed)...
> Task Scheduler log did not help. Like I said the batch file is working
(the
> job gets scheduled) but nothing is is being logged to the log file that
I'm
> trying to report errors to (>> c:\it\pcinfo\batch.log).
>
> "Pegasus (MVP)" wrote:
>
> > - Test the batch file from a Command Prompt before
> > scheduling it.
> > - Check the Task Scheduler log file.
> >
> >
> > "mattr2110" <(E-Mail Removed)> wrote in message
> > news
978B44C-F508-4C85-A983-(E-Mail Removed)...
> > > OK tried it, it schedules the job but nothing in the log file. I'm
not
> > sure
> > > why?
> > >
> > > "Pegasus (MVP)" wrote:
> > >
> > > >
> > > > "mattr2110" <(E-Mail Removed)> wrote in message
> > > > news:5E60A022-CC87-4CCD-9A3F-(E-Mail Removed)...
> > > > > I've created a batch file that will schedule a task on a list of
> > > > computers.
> > > > > I'v tried to add an error log that will report if there where any
> > errors.
> > > > It
> > > > > alwasys reports the same error even if it fails. I'm not sure if
I
> > have
> > > > the
> > > > > error handling setup correct please help.
> > > > >
> > > > > Here is the code
> > > > > @Echo off
> > > > > cd\
> > > > >
> > > > > cls
> > > > >
> > > > > Set /P Ti=Enter the time you wish job to run:
> > > > > Set /p LO=Enter the location of script or program to run:
> > > > >
> > > > > ::1. Configure the path to the PS input list
> > > > > Set PCList=c:\it\pc.txt
> > > > >
> > > > > For /F "tokens=*" %%i in (%PCList%) do (Set Node=%%i) & (Call
:Remote)
> > > > >
> > > > > GOTO :EOF
> > > > >
> > > > > :remote
> > > > >
> > > > > at \\%Node% %ti% /interactive "%LO%"
> > > > >
> > > > >
> > > > > if not errorlevel 1 goto end
> > > > > echo An error occurred during
> > > > > :end
> > > > > echo Job completed: %node% >> c:\logs\batch.log
> > > > >
> > > > >
> > > >
> > > > You have to enable delayed expansion so that %Node% gets
> > > > set the way it should. You must also ensure that your log directory
> > > > exists. Try this variant:
> > > >
> > > > Line1 @Echo off
> > > > Line2 setlocal EnableDelayedExpansion
> > > > Line3
> > > > Line4 ::1. Configure the path to the PS input list
> > > > Line5 Set PCList=c:\it\pc.txt
> > > > Line6 if not exist c:\logs md c:\logs
> > > > Line7
> > > > Line8 Set /P Ti=Enter the time you wish job to run:
> > > > Line9 Set /p LO=Enter the location of script or program to run:
> > > > Line10 if "%Ti%"=="" goto :eof
> > > > Line11 if "%LO%"=="" goto :eof
> > > > Line12
> > > > Line13 For /F "tokens=*" %%i in (%PCList%) do (
> > > > Line14 at \\%%i %ti% /interactive "%LO%"
> > > > Line15 if !ErrorLevel!==0 (
> > > > Line16 echo Job scheduled on %%i >> c:\logs\batch.log
> > > > Line17 ) else (
> > > > Line18 echo An error occurred when scheduling the task on %%i >>
> > > > c:\logs\batch.log
> > > > Line19 )
> > > > Line20 )
> > > > Line21
> > > > Line22 endlocal
> > > >
> > > >
> > > >
> >
> >
> >