等待批处理文件在Powershell中完成处理,然后再执行其他命令? [英] Wait for batch file to finish process in Powershell before executing other commands?

查看:437
本文介绍了等待批处理文件在Powershell中完成处理,然后再执行其他命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行一个Powershell文件,该文件需要执行批处理文件,一旦批处理文件处理完成,则只能继续执行下一个命令.而且,批处理进程不应打开新窗口.

I'm trying to execute a Powershell file which needs to execute batch file and once batch file processing completes then only proceed to next command And, batch process shouldn't open a new window.

$p = Start-Process $dir\bin\stop.bat -Wait -Passthru
$p.WaitForExit()
if ($p.ExitCode -eq 0) {
      java "-Dtar.memoryMapped=true" -Xms8g -Xmx8g -jar oak-run-1.4.6.jar checkpoints $dir\repository\segmentstore | Out-File $log_path\log_checkpoints.txt }

我尝试了上面的代码,但是没有用.

I tried above code but it's not working.

推荐答案

您可以使用它来等待批处理文件完成(在同一窗口中):

You can use this to wait for the batch file to finish (in the same window):

start $dir\bin\stop.bat -Wait -NoNewWindow

如果仍然无法正常工作,您能更具体些吗?

Can you be more specific if it still doesn't work?

这篇关于等待批处理文件在Powershell中完成处理,然后再执行其他命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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