Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

First off, I'm not a sysadmin but a developer.

We're performing some system maintenance that will require our production servers to be offline for a period of ~14 hours. I've been tasked with making sure that any/all scheduled tasks (and there are hundreds across the domain) that were "missed" during that time frame be executed once we're back online.

I'm assuming that there's a relatively easy way to query for scheduled tasks that will execute during a certain time frame, but have no idea how to do this.

We have tasks that run on intervals from 5 minutes to 2 years, so I'd prefer a query of some sort (Powershell or schtasks.exe?) that will simply display the ones that will execute during a particular 14 hour window.

Anyone have any idea around this?

My only idea at this point is to have schtasks.exe dump all the tasks and then do some kind of parsing of results, but that's seems...icky.

Thanks in advance.

share|improve this question
    
Can't you just look that information up in your documentation database? If not, why not? –  John Gardeniers Jun 30 '10 at 2:20
    
What kind of task do you have that only runs every 2 years? –  joeqwerty Jun 30 '10 at 3:05
    
1. I wish we had that kind of documentation database. We do on stuff created over the past 2-3 years, but the real legacy things are more problematic. 2. The main "2-year" task I'm aware of is something that was setup in such a fashion because the original implementer didn't understand the concept of multiple schedules. It could've been done differently, but it is what it is. –  Viflux Jun 30 '10 at 10:29
add comment

2 Answers 2

WMI has the Win32_ScheduledJob class:

The Win32_ScheduledJob WMI class represents a job created with the AT command. The Win32_ScheduledJob class does not represent a job created with the Scheduled Task Wizard from the Control Panel. You cannot change a task created by WMI in the Scheduled Tasks UI.

So it is only part of the answer. A search on MSDN for "Scheduled Task" gets a lot of KB hits... this would the way to find an API.

share|improve this answer
    
Thanks, I'll have a look. –  Viflux Jun 30 '10 at 10:29
add comment

I was able to put together a console application using this library from Code Project.

http://www.codeproject.com/KB/cs/tsnewlib.aspx

Cheers!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.