Windows XP 或更高版本 Windows:如何在不显示窗口的情况下在后台运行批处理文件? [英] Windows XP or later Windows: How can I run a batch file in the background with no window displayed?

查看:21
本文介绍了Windows XP 或更高版本 Windows:如何在不显示窗口的情况下在后台运行批处理文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我已经回答了一个类似的问题(Windows 启动时在后台运行批处理文件),但这次我需要启动一个批处理:

I know I have already answered a similar question (Running Batch File in background when windows boots up), but this time I need to launch a batch:

  • 来自另一批,
  • 没有显示任何控制台窗口,
  • 将所有参数传递给不可见批次.
  • from another batch,
  • without any console window displayed,
  • with all arguments passed to the invisible batch.

第一批在控制台窗口中执行.但是,我不希望第二批(由第一批以异步方式启动)也显示控制台窗口.

The first batch is executed in a console window. However, I do not want the second batch (launched by the first in a asynchronous way) to also display a console window.

我想出了一个可以做到这一点的 VBScript 脚本,我将该脚本作为 答案供其他人参考,但如果您有其他想法/解决方案,请随时贡献.

I have come up with a VBScript script which does just that, and I put the script as an answer for others to refer to, but if you have other ideas/solutions, feel free to contribute.

注意:Windows 命令处理器的控制台窗口被很多人命名为不正确的 DOS 窗口.

Note: The console window of Windows command processor is named not really correct DOS window by many people.

谢谢大家的回答.据我了解,如果我需要异步调用脚本以在不可见模式下运行:

Thank you all for the answers. From what I understand, if I need to asynchronously call a script to run in an invisible mode:

  • 从控制台窗口中已有的第二个脚本开始,start/b 就足够了.
  • 在 Windows 中,无需触发第二个窗口,我的解决方案仍然有效.
  • From a second script already in a console window, start /b is enough.
  • From Windows, without triggering a second window, my solution is still valid.

推荐答案

是否需要第二个批处理文件异步运行?通常,一个批处理文件与 call 命令同步运行另一个,第二个将共享第一个的窗口.

Do you need the second batch file to run asynchronously? Typically one batch file runs another synchronously with the call command, and the second one would share the first one's window.

可以使用start/b second.bat从您的服务器同步启动第二个批处理文件a首先共享您的第一个窗口.如果两个批处理文件同时写入控制台,输出将重叠并且可能无法辨认.此外,您需要在第二个批处理文件的末尾放置一个 exit 命令,否则一旦一切完成,您就会在第二个 cmd shell 中.

You can use start /b second.bat to launch a second batch file asynchronously from your first that shares your first one's window. If both batch files write to the console simultaneously, the output will be overlapped and probably indecipherable. Also, you'll want to put an exit command at the end of your second batch file, or you'll be within a second cmd shell once everything is done.

这篇关于Windows XP 或更高版本 Windows:如何在不显示窗口的情况下在后台运行批处理文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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