Click here to Skip to main content
Sign Up to vote bad
good
See more: C#PowerShell
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:59

Comments
digimanus - 5 Aug '11 - 10:09
create a powershell script that calls all the others and run that script in your Process.Start()
kannan1887 - 5 Aug '11 - 10:38
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.

2 solutions

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
  Permalink  
Comments
Espen Harlinn - 30 Dec '12 - 8:19
Yes, that would be a nice solution :-D
Sergey Alexandrovich Kryukov - 30 Dec '12 - 11:47
Thank you, Espen. —SA
Good suggestion from digimanus - you could even be a bit smarter and create the controller script on the fly.
  Permalink  
Comments
kannan1887 - 5 Aug '11 - 10:42
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
Your Filters
Interested
Ignored
     
0 OriginalGriff 353
1 Sergey Alexandrovich Kryukov 138
2 Mohammed Hameed 123
3 Santhosh G_ 113
4 Ron Beyer 64
0 Sergey Alexandrovich Kryukov 8,266
1 OriginalGriff 6,516
2 CPallini 3,533
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid