Recipe5.9.Listing the Scheduled Tasks


Recipe 5.9. Listing the Scheduled Tasks

Problem

You want to view the list of scheduled tasks on a server.

Solution

Using a graphical user interface

From the Control Panel, open the Scheduled Task applet.

Using a command-line interface

On Windows Server 2003, the following command lists the scheduled tasks on server dc01:

> schtasks /query /s dc01

To get detailed information about each tasks, run the following command:

> schtasks /query /s dc01 /v /fo list

On Windows 2000, the following command lists the scheduled at tasks on server dc01:

> at \\dc01

Using VBScript
' This code lists the scheduled AT tasks on a computer. ' ------ SCRIPT CONFIGURATION ------ strComputer = "<ServerName>" ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colScheduledJobs = objWMI.ExecQuery("Select * from Win32_ScheduledJob") for each objJob in colScheduledJobs    WScript.Echo "Job ID: " & objJob.JobID    for each objProp in objJob.Properties_        WScript.Echo "  " & objProp.Name & ": " & objProp.Value    next  next

Discussion

Another quick way to view the scheduled tasks on a server is to simply browse the Scheduled Tasks share point on the server (\\<SeverName>\Scheduled Tasks). When you create a scheduled task, a job file is created that contains the settings for the task, which is placed in %SystemRoot%\Tasks. This directory is shared out as Scheduled Tasks. Unfortunately, the job files are stored in a binary format, so you cannot simply create or modify them with a text editor. You can, however, copy and paste jobs between servers. If you want to copy a job from ServerA to ServerB, open the Scheduled Tasks share point on both servers, right-click on the target job on ServerA and select Copy, then paste it into the Scheduled Tasks share of ServerB. Make sure any localized settings in the task are modified on ServerB after the copy is complete.

See Also

Recipe 5.7, Recipe 5.8, and MS KB 310424 (HOW TO: Work with Scheduled Tasks on Remote Computers in Windows XP)



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net