Creates and adds multiple jobs, adds multiple, variable tasks to each job, and submits the jobs.

Visual Basic
Edit|Remove
strClusterName = "localhost" 'Change to name of cluster if not run locally.
intJobCount = 3 'Number of jobs to create
intTaskCount = 3 'Must be same number as elements of array.
arrTaskCmds = Array("mpiexec icpi", "mpiexec icpi", "mpiexec icpi")
strUsername = "" 'If empty string, script prompts for username.
strPassword = "" 'If empty string, script prompts for password.
blnIsConsole = True 'True = cmd-line, False = GUI
intHandle = 0
Set objComputeCluster = CreateObject("Microsoft.ComputeCluster.Cluster")
objComputeCluster.Connect(strClusterName)
WScript.Echo "Compute Cluster Name: " & objComputeCluster.Name
For i = 1 To intJobCount
  Set objJob = objComputeCluster.CreateJob
  intJobID = objComputeCluster.AddJob((objJob))
  WScript.Echo "Job ID: " & intJobID
  For j = 1 To intTaskCount
    Set objTask = objComputeCluster.CreateTask
    objTask.CommandLine = arrTaskCmds(j - 1)
    intTaskID = objComputeCluster.AddTask(objJob.ID, (objTask))
    WScript.Echo "Task ID: " & objTask.ID
  Next
  objComputeCluster.SubmitJob intJobID, strUsername, strPassword, _
   blnIsConsole, intHandle
  WScript.Echo "Submitted Job " & intJobID
Next