0

I have a script that creates some scheduled tasks on a Windows Server 2008 R2 box using schtasks.exe, and I'd like that script to set the 'If an instance of the task is already running, run new instances in parallel' setting.

I've poked around the documentation and options for schtasks.exe (which is what I'm using to create the tasks), and don't see any way to set this setting through a script.

Anyone know whether there's an option or other utility that I'm missing?

1 Answers1

1

The only way that I have been able to find to set that option in a scripted way is to edit the XML of the task itself. You are specifically looking for the TaskSettings.MultipleInstances property.

For example, a task that I have on my Windows 7 machine looks, in part, like this:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">

[...]

  <Settings>
    <MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>

[...]

  </Settings>

Notice the <MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy> section. My only thoughts right now are to insert the XML programatically after the task is created.

Wesley
  • 32,690
  • 9
  • 82
  • 117