如何在powershell脚本中一一运行多个脚本 [英] How to run multiple Scripts one by one in a powershell script

查看:51
本文介绍了如何在powershell脚本中一一运行多个脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Powershell 中有 8 个脚本,我一一运行.让我们调用脚本:script1.bat, script2.bat, .., script8.bat.

I have 8 scripts in Powershell which I run one by one. Let's call the scripts: script1.bat, script2.bat, .., script8.bat.

现在我需要一个脚本来运行所有的scripts.bat,但不是同时运行.有没有办法检查每个脚本是否成功?

Now I need a script which runs all scripts.bat one by one, but not simultaneously. And is there a way to check, if each script was successful?

推荐答案

./script1.bat
./script2.bat
./script3.bat
...

我猜你会得到照片.这将按顺序运行它们.确定它们是否成功在很大程度上取决于这些批处理文件如何发出错误信号或成功完成.如果您以 exit/b 234 或类似的错误退出,那么您可以使用 $LastExitCode$? 来确定.您还可以查看这些批处理文件所做的更改是否真正完成,没有其他方法可以确定它们是否成功.

You'll get the picture, I guess. This will run them in sequence. To determine whether they were sucessful or not that depends very much on how those batch files signal errors or sucessful completion. If you exit with exit /b 234 or something similar on an error then you can use $LastExitCode or also $? to determine that. You could also look whether the changes made by those batch files are actually done, of there is no other way of figuring out whether they were sucessful.

这篇关于如何在powershell脚本中一一运行多个脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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