1

I want to run an executable as a foreground process. By this I mean I go to the shell (lets assume cmd) and can launch the executable and remain attached to the console/stdout of that application.

For example:

C:\APPS MyApp.exe

Normally cmd will exit after this command. But I want to remain attached to it till the application exits. Not sure if this is possible in Windows.

Note:

I come from a Linux background, so some of the terminology might not be relevant here.

Eryk Sun
  • 33,190
  • 5
  • 92
  • 111
Qasim Sarfraz
  • 5,822
  • 2
  • 20
  • 26
  • may be you look for `/K` switch `cmd /K MyApp.exe` - https://stackoverflow.com/a/515380/6401656 – RbMm Jun 16 '17 at 01:02
  • It isn't very clear what you're asking, but my best guess is that you need to build the executable as a console application. Or perhaps you just need `start /wait MyApp.exe`. – Harry Johnston Jun 16 '17 at 01:46
  • Is this actually `C:\APPS.bat MyApp.exe`? If so, does it do `START "" %1`? – lit Jun 16 '17 at 02:12
  • If MyApp.exe isn't a console application, then it doesn't automatically inherit the console handle from its parent process (every Windows process has a `ConsoleHandle` for attaching to one and only one console). Even if it inherits console buffer handles in its `StandardInput`, `StandardOutput`, and `StandardError`, they'll be closed at startup (by the kernel32 init routine) since the process doesn't have a valid console handle. – Eryk Sun Jun 16 '17 at 03:51
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Jun 16 '17 at 12:41
  • @jww I respect you opinion but this a use case of Mesos/Marathon application for Windows. Which is or will be a software tool used by most of the developers and hence it makes sense to ask question here. Also, Windows application are managed in a programmatic way so a help/opinion of developer is much more important here. – Qasim Sarfraz Jun 16 '17 at 16:27
  • @QasimSarfraz, have you resolved the problem? If so, you can add your own answer. If not, please update the question to clarify it based on the comments. – Eryk Sun Jun 17 '17 at 01:57
  • Hey, @eryksun I haven't been able to resolve the issue but let me update the question in accordingly with comments. – Qasim Sarfraz Jun 17 '17 at 13:27

0 Answers0