Click here to Skip to main content
13,548,734 members
Rate this:
Please Sign up or sign in to vote.
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 5-Aug-11 3:59am
digimanus 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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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#[^].

Espen-Harlinn 30-Dec-12 8:19am
Yes, that would be a nice solution :-D
SAKryukov 30-Dec-12 11:47am
Thank you, Espen.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Good suggestion from digimanus - you could even be a bit smarter and create the controller script on the fly.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180515.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100