Creates a task, sets its properties, and adds it to an existing job.

Visual Basic
Edit|Remove
strClusterName = "localhost" 'Change to name of cluster if not run locally.
intJobID = 4
Set objComputeCluster = CreateObject("Microsoft.ComputeCluster.Cluster")
objComputeCluster.Connect(strClusterName)
WScript.Echo "Compute Cluster Name: " & objComputeCluster.Name
Set objJob = objComputeCluster.GetJob(intJobID)
WScript.Echo "Job ID: " & objJob.ID
Set objTask = objComputeCluster.CreateTask
objTask.Name = "Task1"
objTask.CommandLine = "mpiexec -n 2 icpi"
objTask.Runtime = "00:01:00" 'Default is Infinite.
objTask.IsExclusive = False
objTask.IsRerunnable = True
objTask.Stdout = "c:\scripts\taskout.txt"
objTask.Stderr = "c:\scripts\taskerr.txt"
objTask.WorkDirectory = "c:\scripts\"
intTaskID = objComputeCluster.AddTask(objJob.ID, (objTask))
WScript.Echo "Added Task " & objTask.ID