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
Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
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
Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 755 views
  • 0 likes
  • 2 in conversation