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

WMI
plus
plus

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

List Scheduled Tasks


Question:

The following script should display a list of scheduled jobs, but it does not. Anyone see what I'm doing wrong?


objLocator = ObjectCreate("WbemScripting.SWbemLocator")
objService = objLocator.ConnectServer(".","root/cimv2","","")
objSecurity = objService.Security_
objSecurity.ImpersonationLevel = 3

query = "SELECT * FROM Win32_ScheduledJob"
colInstances = objService.ExecQuery(query)
taskList=""
; loop once for each instance
ForEach objInstance in colInstances
;Check if Object is EMPTY
type = ObjectTypeGet(objInstance)
if type=="EMPTY" then break
; obtain properties
taskList=itemInsert(objInstance.description,-1,taskList,@tab)
taskList=strReplace(taskList,@tab,@crlf)
Next

message("Scheduled Tasks",taskList)
; close object handles
colInstances=""
objSecurity=""
objService=""
objLocator=""

Answer:

The Win32_ScheduledJob WMI class represents a job scheduled using the Windows NT schedule service. ...

"Windows NT schedule service" means the AT command!

It seem you don't have any jobs scheduled via the AT command.

User Reply:

Well that explains it. Now I just need to figure out how to get to enumerate Scheduled Tasks.

Answer:

Give this a try:
tasklist = FileItemize(StrCat(DirWindows(0),"tasks\*.*"))
AskItemList("Scheduled Tasks",tasklist,@tab,@unsorted,@single)

Article ID:   W16754
File Created: 2005:02:18:12:22:14
Last Updated: 2005:02:18:12:22:14