How to get result or output of ShellExecute?

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?

Thanks

-David
LVL 2
htang_usAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
>>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 );

0
 
htang_usAuthor Commented:
Thanks a lot, jkr,

That perfectly solve my question.
0
All Courses

From novice to tech pro — start learning today.