Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Scheduled tasks can save a great deal of work for administrators, especially if these tasks are well coordinated for minimal impact on users, computers, and the network. However, poorly planned scheduled tasks can cause a number of problems.
For example, if multiple tasks are scheduled to run at the same time, some tasks might interfere with other tasks. Likewise, CPU-intensive or network-intensive tasks scheduled to run at inopportune times might negatively affect users or the network.
To help ensure that tasks are carried out on a regular basis, but without adversely affecting users or the network, it is important for administrators to know which tasks are scheduled to run on their computers and when they are scheduled to run. Enumerating your scheduled tasks can help you minimize the impact of these activities on an individual computer and on the network as a whole.
The Win32_ScheduledJob class can be used to enumerate the following items about the scheduled tasks on a computer:
Scheduled task properties available through the Win32_ScheduledJob class are shown in Table 17.13.
Table 17.13 Win32_ScheduledJob Properties
Property | Description |
---|---|
Caption | Short description (one-line string) of the task. |
Command | Name of the command, batch program, or binary file (along with command-line arguments) that the schedule service will use to invoke the job. Example: "defrag /q /f" |
DaysOfMonth | Days of the month when the job is scheduled to run. If a job is to run on multiple days of the month, these values can be joined in a logical OR. For example, if a job is to run on the 1st and 16th of each month, the value of the DaysOfMonth property will be 1 OR 32768. Values include: 1 1st 2 2nd 4 3rd 8 4th 16 5th 32 6th 64 7th 128 8th 256 9th 512 10th 1024 11th 2048 12th 4096 13th 8192 14th 16384 15th 32768 16th 65536 17th 131072 18th 262144 19th 524288 20th 1048576 21st 2097152 22nd 4194304 23rd 8388608 24th 16777216 25th 33554432 26th 67108864 27th 134217728 28th 268435456 29th 536870912 30th 1073741824 31st |
DaysOfWeek | Days of the week when the job is scheduled to run. If a job is to run on multiple days of the week, these values can be joined in a logical OR. For example, if a job is to run on Mondays, Wednesdays, and Fridays, the value of the DaysOfWeek property will be 1 OR 4 OR 16. Values include: 1 Monday 2 Tuesday 4 Wednesday 8 Thursday 16 Friday 32 Saturday 64 Sunday |
Description | Description of the object. |
ElapsedTime | Length of time that the job has been executing. |
InstallDate | Date the job was created. |
InteractWithDesktop | Boolean value indicating that the specified job is interactive (meaning a user can give input to a scheduled job while it is executing). |
JobID | Identifier number of the scheduled task. |
JobStatus | Status of execution the last time this job was supposed to run. Values are: Success Failure |
Notify | User to be notified upon job completion or failure. |
Owner | User that submitted the job. |
Priority | Urgency or importance of execution of a job. |
RunRepeatedly | Scheduled job should run repeatedly on the days that the job is scheduled. If FALSE, the job is run once. |
StartTime | UTC time to run the job, in the format: YYYYMMDDHHMMSS.MMMMMM UUU Where YYYYMMDD must be replaced by ********. The replacement is necessary because the scheduling service allows jobs to be configured to run only once or to run on a day of the month or week. A job cannot be run on a specific date. For example, ********123000.000000 420 means that the task should run at 12:30 P.M. Pacific time with daylight saving time in effect. In the Universal Time Coordinate (UTC) format: yyyy represents the year. mm represents the month. dd represents the day. HH represents the hour (in 24-hour format). MM represents the minutes. SS represents the seconds. xxxxxx represents the milliseconds. UUU represents the number of minutes difference between the current time zone and Greenwich mean time. |
TimeSubmitted | Time that the job was created. |
UntilTime | Time after which the job is invalid or should be stopped. |
Listing 17.29 contains a script that enumerates the scheduled tasks on a computer. To carry out this task, the script must perform the following steps:
This query returns a collection consisting of all the scheduled tasks created for the computer.
Listing 17.29 Enumerating Scheduled Tasks
|
|
Send us your feedback | « Previous | Next » |