命令提示符运行文件_通过命令提示符运行.exe文件

命令提示符运行文件

命令提示符运行文件

running-an-exe-file-via-command-prompt-00

Most of the time our programs work just like we need them to, but every once in a while you have one that is less than cooperative and leaves you looking for a way to fix its ‘attitude’ problem. Today’s SuperUser Q&A post has some great suggestions to help a frustrated reader get the results he needs.

大多数时候,我们的程序都按照我们需要的方式工作,但是有时您的程序不那么合作,而您每次都在寻找一种解决其“态度”问题的方法。 今天的“超级用户问答”帖子提出了一些很棒的建议,可以帮助沮丧的读者获得所需的结果。

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

问题 (The Question)

SuperUser reader user418119 wants to find a way to keep a program window open long enough to see the results:

超级用户阅读器user418119想要找到一种方法来保持程序窗口打开足够长的时间以查看结果:

I am trying to run an iteration program. Whenever I click on it, it opens then terminates. When I open the input text file using the program, the iteration completes, then the window instantly closes. How can I:

我正在尝试运行迭代程序。 每当我单击它时,它就会打开然后终止。 当我使用该程序打开输入文本文件时,迭代完成,然后窗口立即关闭。 我怎样才能:

1. Run it so that the window does not close (and I can see my results)

1.运行它,以使窗口不会关闭(我可以看到我的结果)

Or

要么

2. Manage to do the same thing via Command Prompt

2.通过命令提示符设法做同样的事情

I am not super familiar with doing stuff via Command Prompt.

我对通过命令提示符执行操作不是很熟悉。

Is there a way to make user418119’s program window stay open long enough to see the results?

有没有一种方法可以使user418119的程序窗口保持打开状态足够长的时间才能看到结果?

答案 (The Answer)

SuperUser contributors mg30rg, misha256, and Ranayna have the answer for us. First up, mg30rg:

超级用户贡献者mg30rg,misha256和Ranayna为我们提供了答案。 首先,mg30rg:

You can create a batch file (.bat) containing two lines. The first one is your application’s command line and the second one is “PAUSE”. It will keep the Command Prompt window open until you press a key or close it using the “X” button. The advantage of this solution is that you can have a separate shortcut to the .bat file so that you can either start your program with or without pausing at the finish.

您可以创建一个包含两行的批处理文件(.bat)。 第一个是应用程序的命令行,第二个是“ PAUSE”。 它将保持命令提示符窗口打开,直到您按下一个键或使用“ X”按钮将其关闭。 该解决方案的优点是,您可以为.bat文件设置一个单独的快捷方式,以便您可以在启动时开始或结束时都不会暂停。

Followed by the answer from misha256:

随后是misha256的答案:

This will leave the Command Prompt window open even after MyApp.exe terminates:

即使MyApp.exe终止,这也会使“命令提示符”窗口保持打开状态:

  • cmd /K “C:\SomeFolder\MyApp.exe”

    cmd / K“ C:\ SomeFolder \ MyApp.exe”

You can create a shortcut with the above. This solution works with all console programs and does not require you to go through Command Prompt every time or modify the original .exe file (which you usually cannot).

您可以使用上面的方法创建快捷方式。 此解决方案可与所有控制台程序一起使用,不需要您每次都经过命令提示符或修改原始.exe文件(您通常不能这样做)。

Incidentally, the /K switch has been around since NT days.

顺便说一句,/ K开关自NT天以来一直存在。

And our final answer from Ranayna:

我们对Ranayna的最终回答是:

Another way which is quite useful if the path to the .exe file is a complicated one: Open a Command Prompt window and just drag the .exe file into the window. The full path to the .exe file will be pasted into the Command Prompt window and you just have to press Enter. There is no need to cd into any paths.

如果.exe文件的路径很复杂,另一种非常有用的方法是:打开命令提示符窗口,然后将.exe文件拖到该窗口中。 .exe文件的完整路径将粘贴到“命令提示符”窗口中,只需按Enter即可 。 有没有必要cd到任何路径。



Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程

翻译自: https://www.howtogeek.com/209694/running-an-.exe-file-via-command-prompt/

命令提示符运行文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值