Win32_ScheduledJob

  • Thread starter Thread starter Jonas
  • Start date Start date
J

Jonas

When i am trying to list scheduled jobs via Win32_ScheduledJob wmi class i
only get the job that has been created by wmi, not the jobs added through
the control panel scheduled tasks. Is this a know issue or should i use
something else than WMI?
 
Hi Jonas,
When i am trying to list scheduled jobs via Win32_ScheduledJob
only get the job that has been created by wmi, not the jobs added
through the control panel scheduled tasks. Is this a know issue or
should i use something else than WMI?

yes, such behavior is by design. WMI uses different technologies to create
scheduled tasks from the one used by Control Panel|Schudled Tasks program.
As a result, WMI script can only query out the tasks created by WMI code
and AT command. The tasks created manually in Control Panel|Scheduled Tasks
cannot be found by WMI code.

However the Scheduled Task SDK API can query all scheduled task jobs
including those created manually by
Control Panel|Scheduled Tasks. But there is not a .NET framework built-in
support to use these API, you need to write some COM Interop in your .NET
program, it would be somehow complicated.

Please refer to the following MSDN doc for the details and one VB.NET
sample project which wrapped those Scheduled Task API:

The Task Scheduler API
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/taskschd/ta
skschd/about_the_task_scheduler.asp

Wrapper Classes for the Windows Task Scheduler
http://www.mvps.org/emorcillo/en/code/shell/tasksched.shtml


Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Gary.

Thank you for your fast reply, and for further guidence in this case.

Regards
Jonas
"Gary Chang[MSFT]" said:
Hi Jonas,
When i am trying to list scheduled jobs via Win32_ScheduledJob
only get the job that has been created by wmi, not the jobs added
through the control panel scheduled tasks. Is this a know issue or
should i use something else than WMI?

yes, such behavior is by design. WMI uses different technologies to create
scheduled tasks from the one used by Control Panel|Schudled Tasks program.
As a result, WMI script can only query out the tasks created by WMI code
and AT command. The tasks created manually in Control Panel|Scheduled
Tasks
cannot be found by WMI code.

However the Scheduled Task SDK API can query all scheduled task jobs
including those created manually by
Control Panel|Scheduled Tasks. But there is not a .NET framework built-in
support to use these API, you need to write some COM Interop in your .NET
program, it would be somehow complicated.

Please refer to the following MSDN doc for the details and one VB.NET
sample project which wrapped those Scheduled Task API:

The Task Scheduler API
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/taskschd/ta
skschd/about_the_task_scheduler.asp

Wrapper Classes for the Windows Task Scheduler
http://www.mvps.org/emorcillo/en/code/shell/tasksched.shtml


Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no
rights.
 
Back
Top