|
|
Command Line Programming with ATUsing DOS Commands To Schedule Programs and Batch ScriptsIntermediate level article describing Command Line programming technique for scheduling applications and batch scripts using the built-in AT command on Windows platforms.
The Windows NT AT (also available under Windows 2000/XP) command is used to maintain a list of tasks to be scheduled on a computer. It is useful because commands can be scheduled from a command line batch file, as well as using the facility to ensure that a specific command is run at some point in the future. To run the AT command, the user should access the Windows Command Line, thus: Start->Run-> Type 'cmd' without quotes Click 'Ok' Once the command prompt appears, then the user can begin to experiment. In the following examples, wherever <keypress> appears, then it refers to a key that the user must press. So, for example, <enter> indicates that the user should press the enter key. The Basic AT CommandIf the command is run by itself, by typing AT at the command prompt, then the following output is likely: C:\>at <enter> There are no entries in the list. In order to retrieve the list of all options, the user can issue one of the following commands: C:\>help at <enter> C:\>help /? <enter> One vital option that is left out of the list accessed by typing 'at' on its own is the 'cmd /c' option which runs an instance of the command interpreter required to process the command associated with the 'at' scheduling. So, anytime that the command to be scheduled is not an executable file, the 'cmd /c' option has to be used. The basic form for the 'at' command then becomes: C:\>at hh:mm cmd /c "command to run" <enter> So, to create a text file in the root, with the current directory listing in it, at 4.30 in the afternoon of the current day, the following can be used: C:\>at 16:30 cmd /c "dir c:\dir-at.txt" <enter> Other options that can be used on the command line include /interactive, which allows the user to interact with the command while it is running. Additional scheduling flexibility is then provided through /every:date and /next:date. In both of these examples, the date is the day of the week or month. Where does the 'at' command relate to command line programming? It can be used to schedule the creation and execution of command line files, very easily with a little ingenuity. The only caveats are that the machine must be switched on and logged in. The Programmer's AlternativeProgrammers also have another option : use a true Win32 program to work on a timed interrupt basis, and run the program at a specific time. Use, and intercept, the WM_TIMER message in conjunction with the time.h functions to decide whether or not to call ShellExecute to launch the application in question. This would be the Win32 approach, but requires that the program is loaded at startup, along with the relevant configuration files. To follow modern Windows programming style guide, it should also only be visually present in the system tray.
The copyright of the article Command Line Programming with AT in Command Line Programming is owned by Guy Lecky-Thompson. Permission to republish Command Line Programming with AT in print or online must be granted by the author in writing.
|
|
|
|
|
|
|
|