WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

NT Native Commands with WinBatch

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Winbatch Hangs with AT Scheduler

Keywords:   Winbatch Hangs with AT Scheduler

Question:

I'm not sure what is happening, but need some help! My winbatch script, which has been running for a week without problems, has hung to the point that even NT task manager cannot terminate the task. I am using NT's scheduler to automatically start my winbatch script each morning at 5:45. The last time it ran, Saturday morning, it never finished. It appears to have completed the the tasks I scripted it to do, but for some reason never terminated. I can't recreate the problem, but I am sure it will come back. Any ideas? Thanks in advance!

Answer:

First some background on the NT scheduler....

The AT command schedules commands and programs to run on a computer at a specified time and date. There are several things to keep in mind when using the AT command to launch a script.

The "AT" command, that allows scheduled program-run. Be careful, it uses a system account (not administrator !!!)

Winbatch scripts running under the AT command have several issues.

  1. The AT command problem is that WinBatch is running then as a service and with a DIFFERENT userid (some low-level default) unless you add special command line options to run it as someone else. So, for example, if you're having problems creating a directory via the NT AT command, that means that apparently the default user does not have permissions to create directories.

  2. Getting userid during netlogon problems: Sometimes you can check environment variables with the Environment function, but I think it does not work since you are not completely logged in yet. Although the environment variables %USERNAME% and %USERDOMAIN% variables are present as soon as the dosbox opens for a logon script.

  3. They are run without any reasonable default environment variables, temp directories, security clearances, etc., etc., so you cannot make any assumptions about paths and stuff.

  4. They are run sort of as a "guest" user where the process running has no network privileges higher than guest. It can't really log into network servers etc etc unless its uses the guest account or something like that. So it is real difficult to access stuff on network servers...

    Now with that said, Use the /interactive parameter, which allows the job to interact with the desktop of the user who is logged on at the time the job runs. Below is an example of how to use the /interactive parameter in the command line:

    at \\server 23:59 /interactive "C:\MYDIR\MYWINBATCH.EXE"
    
  5. Make sure you are not supressing errors using ErrorMode(@off)

  6. Try Adding DebugTrace, or some good error checking, that logs out information about what got executed.

  7. Figure out where exactly in the script it starts to hang....

  8. If all else fails, you might look into the WinBatch TimeWait function to avoid the AT command altogether.

Article ID:   W14655
Filename:   Winbatch Hangs with AT Scheduler.txt
File Created: 2000:11:06:11:58:58
Last Updated: 2000:11:06:11:58:58