如何使用Process.Start()在C#应用程序启动的一个PowerShell窗口中运行多个powershell脚本文件 [英] How to run multiple powershell script files in one powershell window started by a C# application using Process.Start()

查看:242
本文介绍了如何使用Process.Start()在C#应用程序启动的一个PowerShell窗口中运行多个powershell脚本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Process.Start()来启动Powershell来执行脚本。我想在同一个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 !

推荐答案

这样做是个坏主意。流程很好地孤立。你打算如何与脚本沟通?从.NET应用程序调用PowerShell要好得多。

请参阅CodeProject文章:

如何从C#运行PowerShell脚本 [ ^ ]。



-SA
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


来自digimanus的好建议 - 你甚至可以更聪明一点并动态创建控制器脚本。
Good suggestion from digimanus - you could even be a bit smarter and create the controller script on the fly.


这篇关于如何使用Process.Start()在C#应用程序启动的一个PowerShell窗口中运行多个powershell脚本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆