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
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

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.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
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
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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