且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在powershell脚本中一一运行多个脚本

更新时间:2023-02-03 21:07:21

./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.