批处理文件如果未选择命令窗口,则暂停。

huangapple 未分类评论40阅读模式
英文:

batch file pauses if command window not selected

问题

我有一个 .bat 文件,执行以下命令:

cls 
@pushd %~dp0
@echo off
java -Dmypath=path -jar ./my_directory/myjava_program.jar arg1 arg2
@popd
@pause

除此之外,我还有这个限制要求:批处理文件需要通过点击来执行。不允许在命令行中使用附加命令进行执行。

问题:
如果在前台执行脚本,它可以正常运行。但是一旦切换到另一个程序,命令窗口中的输出将会暂停。如果我在命令窗口中点击 ENTER 键,脚本将继续运行。是什么原因导致脚本会暂停?

  • 是否为其他程序执行分配了优先级?
  • 是否与读取行支持有关(我在一些相关帖子中看到过这个问题)?
  • ...

那么,即使我没有选择命令窗口,如何使脚本继续运行?(但它仍然可以可见)

英文:

I have a .bat-file that executes the following commands:

cls 
@pushd %~dp0
@echo off
java -Dmypath=path -jar ./my_directory/myjava_program.jar arg1 arg2
@popd
@pause

In addition to that I have this restraining requirement: The batch file needs to be executed by clicking on it. No execution with additional commands in the command line is possible.

The problem:<br/>
The script runs fine if it is executed in the foreground. But as soon as I change to another program, the output in the command window will pause. If I click ENTER in the command window the script will continue again.
What is the reason the script pauses?

  • priority given for execution of other program?
  • something with the read line support (I read about this issue in a couple of related posts)?
  • ...

And what could be a solution to keep the script running even if I don't have the command window selected? (It can still be visible though)

答案1

得分: 0

尝试右键单击命令窗口,选择属性,然后取消选中“快速编辑模式”。如果已经选中,可能需要关闭/重新打开 DOS 窗口以保持该设置。

英文:

Try to right click on Command window, select properties, and uncheck "QuickEdit Mode" if it is checked. May have to close/reopen dos window to persist that setting.

huangapple
  • 本文由 发表于 2020年7月24日 21:28:16
  • 转载请务必保留本文链接:https://java.coder-hub.com/63074566.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定