Windows批处理文件,等待命令完成? [英] Windows batch file, wait for command to finish?

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

问题描述

我似乎无法弄清楚.

我正在创建一个实时站点并在线部署它

I am creating a live site and deploying it online

批处理文件:

START cmd /K "runas /user:administrator & cd C:\users\MyName\dropbox\!!GIT_HUB_REPOS_ALL\tangycode.github.io & hexo generate & hexo serve --draft"


START /wait "" http://localhost:4000/

事物正在运行命令hexo generate & hexo serve --draft大约需要5到10秒,时间会有所不同.理想情况下,我想等待这种情况发生,然后再转到 http://localhost:4000

The thing is running the command hexo generate & hexo serve --draft takes about 5-10 seconds, time varies. Ideally I want to wait for this to occur before going to live site at http://localhost:4000

由于某些原因,此Windows批处理命令会立即自动打开localhost:4000

Some reason this windows batch command just automatically opens up localhost:4000 right away though

推荐答案

我将使用/B保留相同的进程,而/wait则等到第一个命令完成.除非有更多命令要执行,否则您不需要第二行中的/wait.如果这不起作用,请尝试将cmd/K保留.由于runas是可执行文件,并且批处理一直等到完成,因此可以一起放弃start命令.

I would use /B to stay in the same process and /wait tot wait until the first command is finished. You don't need the /wait in the second line unless there are more commands to follow. If this doens't work, experiment with leaving the cmd /K away. Since runas is an executable and the batch waits until it is finished it's possible you can let away the start command all together.

如果所有这些都不起作用,请插入5个ping命令,这是等待±1秒的经典方法.

If all this doesn't work insert 5 ping commands, that is the classic way to wait for ± one second.

START /B /wait "runas /user:administrator & cd C:\users\MyName\dropbox\!!GIT_HUB_REPOS_ALL\tangycode.github.io & hexo generate & hexo serve --draft"


START /B "" http://localhost:4000/

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

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