如何抑制“终止批处理作业"?在 cmd.exe 中 [英] How can I suppress the "terminate batch job" in cmd.exe
问题描述
我正在寻找一种机制来抑制终止批处理作业?(是/否)"每当我在从批处理文件启动的程序中按 CTRL-C 时都会收到邀请:
I'm looking for a mechanism for suppressing the "Terminate batch job? (Y/N)" invitation that I get whenever I press CTRL-C in a program started from a batch file:
批处理文件:jsshell.bat:
batch file: jsshell.bat:
@echo off
java -jar build-scriptscontrib
hino1.7R1.jar
然后通过以下方式在 cmd shell 上启动它:
and then starting it on cmd shell by:
> jsshell.bat
这给了我一个可以通过 CTRL-C 退出的 shell,但在调用 CTRL-C 后我得到一个终止批处理作业(是/否)?";令人讨厌和烦人的消息.我怎样才能让它退出而不必按y"?
which gives me a shell that can be exited by CTRL-C but after invoking CTRL-C I get a "Terminate batch job (Y/N)?" message which is nasty and annoying. How can I get it to just exit without me having to press 'y'?
推荐答案
不要忘记考虑通过避免使用批处理脚本来解决问题.
Don't forget to consider working around the problem by avoiding batch scripts.
- Doskey 宏 可以替代上面引用的单行批处理脚本.(将它们加载到您的 自动运行脚本.)
- Cscript.exe 可在每台现代 Windows 机器上使用,并且可以从命令行运行 JavaScript 和 VBScript 程序
- 如果您将最喜欢的脚本语言(Perl、Python、Ruby 等)的文件扩展名添加到 PATHEXT 环境变量并将脚本添加到您的路径中,则无需批处理脚本即可直接执行它们.
- Doskey macros can replace one-liner batch scripts like the one quoted above. (Load them up in your Autorun script.)
- Cscript.exe is available on every modern Windows machine and can run JavaScript and VBScript programs from the command line
- If you add file extensions for your favorite scripting language (Perl, Python, Ruby, etc.) to your PATHEXT environment variable and add the script to your path, you can execute them directly without a batch script.
这篇关于如何抑制“终止批处理作业"?在 cmd.exe 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!