简体   繁体   English

自动:执行后如何保持cmd窗口打开?

[英]Automise: how to keep cmd window open after executing?

I have an atp4 automise project file. 我有一个atp4自动项目文件。 When I double click on it an ATCMD.exe window pops up and executes the script, but immediately closes upon completion. 当我双击它时, ATCMD.exe弹出ATCMD.exe窗口并执行该脚本,但完成后立即关闭。

I would like to see what's going on during the execution, and therefore would like the runtime window to stay open so I can see what it's output is. 我想看看执行期间发生了什么,因此希望运行时窗口保持打开状态,以便可以看到它的输出。
How can I prevent the window from closing after it finishes executing the script? 如何防止窗口在执行完脚本后关闭?

I don't know atp4 but with a batch script you should be able to get what you want (the cmd tag implies you have Windows command prompt available). 我不知道atp4但是使用批处理脚本,您应该能够获得所需的内容( cmd标记表示您具有Windows命令提示符)。 All you'll have to do in your batch script is put the name of your atp4 automise project file (use double quotes if it contains spaces), add a pause under it and save it with a .bat extension in the same directory as your atp4 automise file . 在批处理脚本中,您atp4就是将atp4自动项目文件的名称放到文件中(如果包含空格,请使用双引号),在其下添加一个pause ,并以.bat扩展名保存在与您的目录相同的目录中atp4自动文件 You can then double-click on the batch-file and it will launch your atp4 automise project file and call the pause command after it. 然后,您可以双击批处理文件,它将启动atp4自动项目文件,并在其后调用pause命令。 The pause will cause the command window to remain open untill you press on a key. pause将使命令窗口保持打开状态,直到您按某个键。 Your batch-file should look like this: 您的批处理文件应如下所示:

@echo off
"<name_and_ext_atp4_automis_file>"
pause

The @echo off is not mandatory but it prevents the cmd to print each command it executes in your batch-file. @echo off不是强制性的,但是它阻止cmd打印在批处理文件中执行的每个命令。

If you prefer that only the Enter key can make you "exit" the window, you can replace pause with set /p =Press the Enter key to exit... . 如果您只希望使用Enter键可以使您“退出”窗口,则可以使用set /p =Press the Enter key to exit...来代替pause set /p normally waits on input from the user to set a variable with it (user's input ends when he/she presses enter). set /p通常等待用户输入以设置变量(用户按回车键后输入结束)。 set /p without giving a variable to store the input in is as telling cmd to wait untill the user presses enter. set /p而不给出变量来存储输入,就像告诉cmd等到用户按下Enter一样。

EDIT : There is a little remark I'd like to add. 编辑 :我想补充一点。 Normally in windows the path to a file should be enough to call the program that should open it (the program linked to the file extension is called automatically). 通常,在Windows中,文件路径应足以调用应打开该文件的程序(链接到文件扩展名的程序会自动调用)。 It should have the same effect as double clicking on the file in the explorer GUI but some files (like batch scripts) may need some additional commands to make it "go smooth" inside a batch script too. 它应具有与在资源管理器GUI中双击文件相同的效果,但某些文件(如批处理脚本)可能还需要一些其他命令以使其在批处理脚本内“顺利运行”。 As I don't know atp4 I cannot control it for this case. 由于我不知道atp4 ,因此无法控制这种情况。 I'd advise you to try out the script and maybe indicate in the comments if it worked fine. 我建议您尝试一下脚本,并在注释中指出是否可以正常工作。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM