bat 文件启动 exe 并等待标准输出中的字符串

发布于 2024-10-06 03:02:41 字数 98 浏览 0 评论 0原文

各位,

是否可以创建一个启动可执行文件并等待标准输出中预先确定的字符串的 bat 文件。当找到该字符串时,批处理文件将退出(exe 可以继续运行)。这怎么可能实现呢?

Folks,

Is it possible to create a bat file that launches an executable and waits for a pre-determined string in the standard output. When that string is found, the batch file will exit (the exe can continue running). How could this be accomplished?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海不蓝 2024-10-13 03:02:41

简而言之,不。

请注意,最初 MS-DOS 是运行 Windows 的操作系统。现在它是一个模拟早期操作系统的应用程序。解决问题的方法可能涉及使用从 MS-DOS 内部调用的应用程序,该应用程序将在 MS-DOS 命令库中执行这种逻辑(即 IF(file_is_present_with_string)THEN {...})。

Powershell 是一种功能强大的脚本语言,允许您执行以前在 MS-DOS 中无法执行的许多操作,例如从一个 MS-DOS 命令(例如 ipconfig /all)获取输出并将其重新格式化为不同的布局,可能将其用作另一个命令的输出输入参数(例如,从 ipconfig 选择一个值并在另一个命令中使用它)。尽管它支持 MS-DOS 命令执行,但它是通过使用 CMDLET(读作 command-let)来实现的,CMDLET 是一个独立的应用程序,设计为在 Powershell 内运行。还有许多其他 CMDLET 可能可以帮助解决您的问题。

In short, no.

Note that originally MS-DOS was an operating system in which Windows ran. Now it is an application that simulates the earlier OS. The way to solve your would possibly involve using an application called from within MS-DOS, that will perform this kind of logic (i.e. IF(file_is_present_with_string)THEN {...}) in the MS-DOS command library.

Powershell is a powerful scripting language allowing you to perform many operations previously unavailable in MS-DOS, such as take the output from one MS-DOS command (e.g. ipconfig /all) and reformat it into a different layout, possibly using it as another command's input parameters (e.g. select a value from ipconfig and use it in another command). Although it supports MS-DOS command execution, it does so through the use of CMDLETs (pronouned command-let) which is a self-contained application designed to run inside Powershell. There are many other CMDLETs out there that might be able to help solve your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文