Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using Process.Start() to start Powershell to execute a script. I would like to run multiple script files one after the other in the same Powershell Window so that they all have the same session.

Please let me know if there is a way to achieve this .

Thanks in Advance !
Posted
Comments
Herman<T>.Instance 5-Aug-11 10:09am    
create a powershell script that calls all the others and run that script in your Process.Start()
deepthakannan 5-Aug-11 10:38am    
This is how we are executing them now. We would like to have more control over the scripts. For example, I would like to run script5 after running script3 skipping script4.

Doing so is a bad idea. Processes are well isolated. How are you going to communicate with the script? It's much better to invoke PowerShell from your .NET application.
Please see this CodeProject article:
How to run PowerShell scripts from C#[^].

—SA
 
Share this answer
 
Comments
Espen Harlinn 30-Dec-12 8:19am    
Yes, that would be a nice solution :-D
Sergey Alexandrovich Kryukov 30-Dec-12 11:47am    
Thank you, Espen.
—SA
Good suggestion from digimanus - you could even be a bit smarter and create the controller script on the fly.
 
Share this answer
 
Comments
deepthakannan 5-Aug-11 10:42am    
If I create a controller script on the fly, I have to call Process.Start(createdonthefly.ps1) for every controller script I create. We'll lose sessions if we do this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900