第二个蝙蝠未执行PowerShell脚本
PowerShell脚本调用以下BAT文件,但是仅执行BAT1.BAT
#first bat
Start-Process "C:\bat1.bat" -Wait
#run second bat
Start-Process "C:\bat2.bat" -Wait
#run last bat
cmd.exe /c '\last.bat'
。
the below bat files are being called by PowerShell script, however only bat1.bat is executed the others bat2.bat and last.bat are not being called
#first bat
Start-Process "C:\bat1.bat" -Wait
#run second bat
Start-Process "C:\bat2.bat" -Wait
#run last bat
cmd.exe /c '\last.bat'
You r support is highly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用以下操作:
我制作了以下.bat文件:
bat1.bat
bat2.bat
final.bat
当PS脚本运行时,所有3次运行。
如果以前的过程完成,则将写入主机放在控制台中。
编辑:
对不起,我以前没有给出太多解释。
您的问题是,一个.bat文件之一未完成。
您的语法应该运行bat1.bat和bat2.bat。 “ cmd.exe /c” \ last.bat“将失败。 。
不是.bat代码。
验证您的脚本将运行,我不需要使用设置。进入下一个过程。
Try using this:
I made the following .bat files:
bat1.bat
bat2.bat
final.bat
When the PS script was ran, all 3 ran as one would expect.
Putting the Write-Host will show in the console if the previous process finished.
Edit:
I didn't give much explanation before, sorry.
Your issue is that one of the .bat files is not finishing.
The syntax you had should have run bat1.bat and bat2.bat. The "cmd.exe /c "\last.bat" would fail. You need the "c:\last.bat" if you aren't going to set the path to c:. If you did that, you would want ".\last.bat"
To make sure that your script would work, I made 3 basic .bat files whose functions were solely to log a string associated with them. Doing this guaranteed that if anything went wrong, it was with the PS code and not the .bat code.
After verifying your script would run, I made the one I provided. Using Set-location isn't necessary, but I think it makes the code look cleaner. The Write-Host after each process is logging in the PS console that the script is moving on to the next process.
为什么不尝试
完全避免Powersmell?
Why not try
and avoid Powersmell altogether?