[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


How to get result or output of ShellExecute?

Posted on 2004-10-21
Medium Priority
Last Modified: 2013-11-20
I am writing a MFC program to control RCS (Revision Control System from GNU).

The path has been set correctly.

The command I use is this

::ShellExecute ( NULL, _T("open"), _T("ci"), _T("-x,v -t-\"Initial Revision\" c:\\abc.txt c:\\temp\\RCS\\abc.txt,v"), NULL, SW_SHOW );

This corresponds to the DOS command:
  ci -x,v -t-"Initial Revision" c:\\abc.txt c:\\temp\\RCS\\abc.txt,v
This DOS command can be executed correctly.

The return value is 42.

The DOS window disappears very quickly, so I can't see the output of "ci" command.

The problem is when I executes this command from my MFC program, the file is not checked in. But I don't know what happened during command execution.

I also try to put "> c:\\result.txt" at the end of parameter, want to put output in a ASCII file. But the result.txt is not created at all.

So is there some solution to capture the output of command execution or let the DOS window stay even after command is done so I can see the output?


Question by:htang_us
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 86

Accepted Solution

jkr earned 400 total points
ID: 12372945
>>I also try to put "> c:\\result.txt" at the end of parameter

This is because the output redirection is done by the shell, so that should be

cmd.exe /c   ci -x,v -t-"Initial Revision" c:\\abc.txt c:\\temp\\RCS\\abc.txt,v > c:\\result.txt

Actually, your problem seems to be that you are not using the .exe extension like e.g.

::ShellExecute ( NULL, _T("open"), _T("ci.exe"), _T("-x,v -t-\"Initial Revision\" c:\\abc.txt c:\\temp\\RCS\\abc.txt,v"), NULL, SW_SHOW );


Author Comment

ID: 12373377
Thanks a lot, jkr,

That perfectly solve my question.

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question