VB Script had its days (or decades) but it is on the way out. Here's a PowerShell script (I named it RunFlow.ps1) that can take a project (full path) and flow name and run it. It also Saves the project file after running the flow (which will update any project results like log, ODS, etc).
# check for an input file
if ($args.Count -eq 2)
{
$fileToProcess = $args[0]
$flowToRun = $args[1]
}
else
{
Write-Host "EXAMPLE Usage: RunFlow.ps1 path-and-name-EGP-file process-flow"
Exit -1
}
# check that the input file exists
if (-not (Test-Path $fileToProcess))
{
Write-Host "$fileToProcess does not exist."
Exit -1
}
# change this if running a different version of EG
$egVersion = "SASEGObjectModel.Application.8.1"
# create an instance of the EG automation model
$eguideApp = New-Object -comObject $egVersion
Write-Host $eguideApp.Name $eguideApp.Version
Write-Host "Opening " $fileToProcess ", looking to run " $flowToRun
$project = $eguideApp.Open("$fileToProcess", "")
# Show all of the process flows in the project
$pfCollection = $project.ContainerCollection
foreach ($pf in $pfCollection)
{
if ($pf.ContainerType -eq 0)
{
if ($pf.Name -eq $flowToRun)
{
Write-Host "Running " $flowToRun
$pf.Run()
Write-Host "Saving updated " $project.Name
$project.Save()
}
}
}
$project.Close()
# Quit (end) the application object
$eguideApp.Quit()
You run it like this:
.\RunFlow.ps1 "C:\Projects\Automation\Daily_Job.egp" "Prod Flow"
Enterprise Guide 8.5.0.0
Opening C:\Projects\Automation\Daily_Job.egp , looking to run Prod Flow
Running Prod Flow
Saving updated Daily_Job
Can definitely use more error checks for a more robust script. See Doing More with SAS Enterprise Guide Automation for more information about the EG automation model.
... View more