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
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
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.
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()
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
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.