|
|
|
| 24 February 2003 | atGetJobs() |
| Author | Florian Lagg, ICQ 167357108 |
| Action | get all task scheduler jobs on a local or remote NT/2000/XP-Machine. uses WMI, for NT 4.0 you have to install WMI first. |
| Syntax | atGetJobs ($sComputer) |
| Parameters | |
| Remarks | on NT 4.0 install WMI |
| Returns | -1 = error: WMI probably not installed or -2 = error: WMI query for scheduled jobs fails or an array with all jobs on a specific host. This array has the following properties: JobID, Caption, Command, DaysOfMonth, DaysOfWeek, Description, ElapsedTime, InstallDate, InteractWithDesktop, JobStatus, Name, Notify, Owner, Priority, RunRepeatedly, StartTime, Status, TimeSubmitted, UntilTime |
| Dependencies | WMI must be installed on NT 4.0 Win 2000 and XP have it installed |
| Examples |
$Jobs = atGetJobs ("") ; all Jobs from localhost
$Jobs = atGetJobs ("server1") ; all Jobs from "server1"
|
| Source |
FUNCTION atGetJobs ($scomputer)
IF ($scomputer = "")
$scomputer = "." ; (=localhost)
ENDIF
$objwmiservice = GetObject("winmgmts:"+"{impersonationLevel=impersonate}!\\"+$scomputer+"\root\cimv2")
IF @error = 0
$objwmiservice_schedule = $objwmiservice.execquery("Select * from Win32_ScheduledJob")
IF @error = 0
$atgetjobs = $objwmiservice_schedule
ELSE
$atgetjobs = -2
ENDIF
ELSE
$atgetjobs = -1
ENDIF
$objwmiservice = 0
ENDFUNCTION ; - atGetJobs -
|
|
|
|