[英]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.