How to run multiple Scripts one by one in a powershell script

≯℡__Kan透↙ 提交于 2019-12-11 11:59:44

问题


I have 8 scripts in Powershell which I run one by one. Let's call the scripts: script1.bat, script2.bat, .., script8.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?


回答1:


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

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.



来源:https://stackoverflow.com/questions/17966263/how-to-run-multiple-scripts-one-by-one-in-a-powershell-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!