JSI Tip 0243 - Debugging scheduled jobs.

Jerold Schulman

September 12, 1997

1 Min Read
ITPro Today logo

Does your batch job run fine but fails when run from the scheduler?

Jobs executed by the scheduler run under the user context of the schedule service (Control Panel / Services /Schedule / Start Up). If the job requires interaction with the desktop, it is preferable to use the built in system account and check Allow service to interact with desktop. Use the /interactive switch when invoking the AT command.

Unfortuneatly, the system account is local and has no network access. You can circumvent this problem with:

net use Drive: \ServerNameShareName /U:DomainNameUserName password

where the account used has the required permissions (and a password that never expires).

You can also configure the Scheduler to run under the context of a Domain/Admin account. Create a new user account that is a member of the domain admin group with a non-blank, non-expiring password. In user manager for domains, give it all the advanced rights it may ever need including logon as a service and batch job.

To debug your job, type: AT hh:mm /interactive cmd.exe /k or soon /interactive cmd.exe /k

This will open a command prompt under the schedule service user context.

You can now run your batch job in this window and use echo and pause to help pinpoint the problem.

It is important to realize that the environment variables available to your scheduled job may differ from the environment variables available when you run a batch. Type SET >Drive:DirectorySET.LOG in this window to pipe the schedule service environment variables to a log file so you can inspect them. Here are some of mine:

COMPUTERNAME=ALRMP
ComSpec=C:WINNTsystem32cmd.exe /X /e:2048
NTResKit=D:reskit40
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=C:WINNTsystem32replimportscripts;C:WINNTsystem32;C:WINNT;C:Util
PATHEXT=.COM;.EXE;.BAT;.CMD
PROCESSOR_ARCHITECTURE=x86
SystemDrive=C:
SystemRoot=C:WINNT
USERDOMAIN=NT AUTHORITY
USERNAME=SYSTEM
USERPROFILE=C:WINNTProfilesDefault User
windir=C:WINNT

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like