Skip navigation

JSI Tip 0243 - Debugging scheduled jobs.

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: \\ServerName\ShareName /U:DomainName\UserName 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:\Directory\SET.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:

ComSpec=C:\WINNT\system32\cmd.exe /X /e:2048
USERPROFILE=C:\WINNT\Profiles\Default User

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.