1

In Windows Server 2008 R2, I want to set up a Scheduled Task to run a batch script on the following condition

  -The task should only run once another task, that also runs a batch script, has   
   completed. How do I do that?

Note: Both task are set to run once daily.

Thanks!

1 Answer 1

1

Two ways that I see to do this:

  1. From within the first task, if it successfully completes, then immediately schedule the second task from the command line. Use schtasks.exe /create /? for syntax.

  2. If you want the second task to run nearly immediately, Call the second task, when you detect the first task has completed. If you want say, an hour to pass, use a 'wait.exe' type tool to temporarily pause the script, then execute after the time has passed.

3
  • Cool thank you. I see that you can also use the schtasks command to call a specific task - How do I get the ID or the Process ID of a task? Commented Jul 3, 2013 at 17:47
  • Mmm. Do you mean of the task created by the Scheduled Task? it is a batch program. Tasklist.exe - might get you to it. Also, check wmic.exe.
    – RobW
    Commented Jul 3, 2013 at 21:25
  • There is another program called getpids.exe scheibli.com/projects/getpids . It will return the current PID, parent pids (one of which is your cmd.exe). Youu would call it from your batch program and parse for Process ID.
    – RobW
    Commented Jul 4, 2013 at 0:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .