SAS Enterprise Guide

Desktop productivity for business analysts and programmers
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
isek
Obsidian | Level 7

Hello,


My goal is to launch a batch that launches several PowerShell scripts, each of which executes a SEG project.
My batch launches a PowerShell script, this PowerShell script launches several PowerShell scripts and each script runs a SEG project.
The first SEG project starts well and the others launch without really executing the body of the program which makes me logs of 10 KB and without error message on the execution of the program.

 

I think that the connection to SasApp is not done, yet I put phony codes to save some time for SasApp to connect.

 

If anyone to a solution or idea of the approach to follow it would be great

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

This might not be the real solution, but have you tried launching your scripts in different processes?  Do they each work when run in succession from a command shell?

 

startprocess powershell -argument "path\project1.ps1" -Wait
startprocess powershell -argument "path\project2.ps1" -Wait
startprocess powershell -argument "path\project3.ps1" -Wait
startprocess powershell -argument "path\project4.ps1" -Wait
Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

View solution in original post

3 REPLIES 3
ChrisHemedinger
Community Manager

Can you share an example of a simple script -- one that's not working the way you expect?

 

One idea -- make sure that you Close / null out the Project and App objects you create during each script, so the process can clean up as much as possible between runs.

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
isek
Obsidian | Level 7

I have four scripts like project1.ps1, then in my batch runs the script Allproject1.ps1

 

path\Allproject1.ps1 :


path\project1.ps1
path\project2.ps1
path\project3.ps1
path\project4.ps1

 

project1.ps1 :


$rep_init="C:\Windows"

$rep_projet="$rep_init\......"
$rep_log="$rep_projet\Log"

$eguideApp = New-Object -comObject SASEGObjectModel.Application.7.1


############## project SAS

$projName = "$rep_projet\H_project1.egp"
$project = $eguideApp.Open("$projName", "")
$projectLog = $project.ProjectLog

 

# Show all of the process flows in the project
$pfCollection = $project.ContainerCollection

 

###################### FLUX

Write-Host "Clearing the project log in EG project: " $project

# Clear the project log:
$projectLog.Clear()

 

# Other available project log operation examples...

# Enable/disable project log:
$projectLog.Enabled = $true

 

# Get project log text:
$strProjectLog = $projectLog.Text
Write-Host "Project log text: " $strProjectLog

$pf=$pfCollection.item("Flux de processus")
Write-Host " 1 - EXECUTION DU PREMIER FLUX DE PROCESSUS " $pf.Name


# To RUN a process flow, simply use $pf.Run()
$pf.Run()

 

# Save project log to a file:
$projectLog.SaveAs("$rep_log\Log_project1.txt")

$project.Close()

$eguideApp.Quit()

ChrisHemedinger
Community Manager

This might not be the real solution, but have you tried launching your scripts in different processes?  Do they each work when run in succession from a command shell?

 

startprocess powershell -argument "path\project1.ps1" -Wait
startprocess powershell -argument "path\project2.ps1" -Wait
startprocess powershell -argument "path\project3.ps1" -Wait
startprocess powershell -argument "path\project4.ps1" -Wait
Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1254 views
  • 0 likes
  • 2 in conversation