gpt4 book ai didi

java - 从java运行交互式bat文件?

转载 作者:行者123 更新时间:2023-12-01 15:23:16 26 4
gpt4 key购买 nike

需要帮助从 java 调用批处理文件,该文件是交互式的,并且不应在新窗口中打开。尝试使用运行时调用 --- cmd/c start batchfilename --- 但它在新窗口中打开。我需要在调用批处理文件的同一个窗口中聚焦并执行它。

最佳答案

Windows有一个启动命令:

C:\>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/AFFINITY <hex affinity>] [/WAIT] [/B] [command/program]
[parameters]

"title" Title to display in window title bar.
path Starting directory
B Start application without creating a new window. The
application has ^C handling ignored. Unless the application
enables ^C processing, ^Break is the only way to interrupt
the application
I The new environment will be the original environment passed
to the cmd.exe and not the current environment.
MIN Start window minimized
MAX Start window maximized
SEPARATE Start 16-bit Windows program in separate memory space
SHARED Start 16-bit Windows program in shared memory space
LOW Start application in the IDLE priority class
NORMAL Start application in the NORMAL priority class
HIGH Start application in the HIGH priority class
REALTIME Start application in the REALTIME priority class
Press any key to continue . . .

尝试运行start(而不是cmd)。如果这没有帮助,您可以捕获用户输入/输出并通过管道传输到 Process .

关于java - 从java运行交互式bat文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10551312/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com