简体   繁体   English

我如何运行.exe但保持在同一个命令窗口(不打开新的)?

[英]How do I run a .exe but stay in the same command window (not open a new one)?

I have searched for many weeks to solve my problem and can't find a good way of doing it that works on every machine I may need to use. 我已经搜索了好几个星期来解决我的问题,但找不到一个好的方法,可以在我可能需要使用的每台机器上运行。

I know START command opens a new window to do the .exe, but I want to stay in the same window and run the .exe 我知道START命令会打开一个新窗口来执行.exe,但是我希望保持在同一个窗口并运行.exe

(because I want my batch file to continue ONLY WHEN THE .EXE has finished running) (因为我希望我的批处理文件只在.EXE运行完毕时继续)

I have found that on some computers when I .exe it opens a new window and other computers is stays in the same window which makes me think my code is fine but there is a setting somewhere on the computers that is different. 我发现在某些计算机上,当我执行.exe时会打开一个新窗口而其他计算机停留在同一个窗口中,这让我觉得我的代码很好但是计算机上的某个地方有不同的设置。

Can you help? 你能帮我吗? What are my options? 我有什么选择? The .exe I am running is NASTRAN which is an engineering solver that runs in command window. 我正在运行的.exe是NASTRAN,它是一个在命令窗口中运行的工程求解器。

To wait for the command to terminate you should use the WAIT flag: 要等待命令终止,您应该使用WAIT标志:

start /WAIT c:/windows/system32/notepad.exe

You could start an application without creating a new window using the B flag: 您可以在不使用B标志创建新窗口的情况下启动应用程序:

start /WAIT /B "c:/windows/system32/cmd.exe"

You should also try reading the help text for the start command: 您还应该尝试阅读start命令的帮助文本:

start /?

您可以使用cmd /k example.exe

You probably have a different variant of the .exe on some machines which is called only there, and spawns a separate window, for reasons I cannot know. 你可能在一些只在那里调用的机器上有一个不同的.exe变种,并产生一个单独的窗口,原因我不知道。 Search for the .exe file on all machines and compare. 在所有计算机上搜索.exe文件并进行比较。

Also, post your batch file code so we can exactly see how you start the .exe. 另外,发布您的批处理文件代码,以便我们可以准确地看到您如何启动.exe。

You could consider not using start at all. 您可以考虑不使用start Simply start the executable directly. 只需直接启动可执行文件。

Did you try using call in the batch file. 您是否尝试在批处理文件中使用调用。 it runs the exe in the same window. 它在同一窗口中运行exe。 as the batch file. 作为批处理文件。 The next statement in the batch file is executed after this exe is finished running 批处理文件中的下一个语句在此exe完成运行后执行

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 Windows 命令提示符开始运行 Window(Windows 键 + R)? 我还想定义 WHAT 程序 Run 应该在同一命令中打开 - How do I start Run Window (Windows key + R) from Windows Command Prompt? I also want to define WHAT program Run should open in the same command 如何从sh脚本打开新的命令行窗口,然后传入多个命令 - How do I open a new command line window from an sh script and then pass in multiple commands 如何打开cmd.exe并执行命令? - How do I open cmd.exe and execute a command? 如何在一个 exe 文件或其他文件中运行多个命令? - How can i run multiple command in a one exe file or others? python:windows:子进程在新命令 window 中打开 a.bat 文件并运行 - python : windows : Subporcess open a .bat file in a new command window and run 如何从 cmd.exe 在给定目录中打开资源管理器窗口? - How do I open an Explorer window in a given directory from cmd.exe? Windows:如何在新命令窗口中以某种方式在进程完成或崩溃时关闭窗口? - Windows: how can I run something in a new command window in such a way that the window closes when the process finishes or crashes? 从命令行运行 m 文件时如何隐藏“MATLAB 命令行窗口”? - How do I hide “MATLAB Command Window” when I run an m-file from command line? 如何从另一个 C++ .exe 打开 .exe? - How do I open an .exe from another C++ .exe? Windows 终端 - 如何打开新终端 Window 而不是新标签? - Windows Terminal - How Do I Open a New Terminal Window Instead of New Tab?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM