How to get result or output of ShellExecute?

Posted on 2004-10-21
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
    LVL 86

    Accepted Solution

    >>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 );

    LVL 2

    Author Comment

    Thanks a lot, jkr,

    That perfectly solve my question.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
    Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
    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.
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    884 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now