如何从另一个 bat 文件在后台运行 bat 文件? [英] How do I run a bat file in the background from another bat file?

查看:36
本文介绍了如何从另一个 bat 文件在后台运行 bat 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个设置"脚本,我在早上运行它可以启动我需要的所有程序.现在其中一些需要额外的环境设置,所以我需要将它们包装在小的 BAT 脚本中.

I have a "setup" script which I run in the morning which starts all the programs that I need. Now some of those need additional setup of the environment, so I need to wrap them in small BAT scripts.

如何在后台在 Windows XP 上运行这样的脚本?

How do I run such a script on Windows XP in the background?

CALL env-script.bat 同步运行,即设置脚本只有在 env-script 中的命令终止后才能继续.

CALL env-script.bat runs it synchronously, i.e. the setup script can continue only after the command in the env-script has terminated.

START/B env-script.bat 在同一个命令提示符下运行另一个 CMD.exe 实例,使其处于非常混乱的状态(我看到嵌套的 CMD.exe 的输出,键盘死了一段时间,脚本没有执行).

START/B env-script.bat runs another instance of CMD.exe in the same command prompt, leaving it in a really messy state (I see the output of the nested CMD.exe, keyboard is dead for a while, script is not executed).

START/B CMD env-script.bat 产生相同的结果.CMD 中的标志似乎都不符合我的要求.

START/B CMD env-script.bat yields the same result. None of the flags in CMD seem to match my bill.

推荐答案

实际上,以下对我来说工作正常并创建新窗口:

Actually, the following works fine for me and creates new windows:

test.cmd:

@echo off
start test2.cmd
start test3.cmd
echo Foo
pause

test2.cmd

@echo off
echo Test 2
pause
exit

test3.cmd

@echo off
echo Test 3
pause
exit

将其与 start 的参数结合使用,例如 /min,正如 Moshe 指出的那样,如果您不希望新窗口在您面前生成.

Combine that with parameters to start, such as /min, as Moshe pointed out if you don't want the new windows to spawn in front of you.

这篇关于如何从另一个 bat 文件在后台运行 bat 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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