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

Visual Basic
Edit|Remove
strClusterName = "localhost" 'Change to name of cluster if not run locally.
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
Set objJob = objComputeCluster.CreateJob
intJobID = objComputeCluster.AddJob((objJob))
WScript.Echo "Job ID: " & intJobID
For i = 1 To intTaskCount
  Set objTask = objComputeCluster.CreateTask
  objTask.CommandLine = arrTaskCmds(i - 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