Creates and adds multiple jobs, adds one task 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
strCommandLine = "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
  'Create job.
  Set objJob = objComputeCluster.CreateJob
  'Add job.
  intJobID = objComputeCluster.AddJob((objJob))
  WScript.Echo "Job ID: " & intJobID
  'Create task.
  Set objTask = objComputeCluster.CreateTask
  objTask.CommandLine = strCommandLine
  'Add task to job.
  intTaskID = objComputeCluster.AddTask(objJob.ID, (objTask))
  WScript.Echo "Task ID: " & objTask.ID
  'Submit job.
  objComputeCluster.SubmitJob intJobID, strUsername, strPassword, _
   blnIsConsole, intHandle
  WScript.Echo "Submitted Job " & intJobID
Next